PHP PDO排序结果列表按字母顺序排序

时间:2015-01-02 00:08:12

标签: php mysql pdo sql-order-by

我有以下代码:

    $sqlQueryVendorId = $dbh->prepare("SELECT business_name, profile_id 
        FROM $tableVendorProfiles 
        WHERE ((vendor_id_1 = :vendor_id_1 OR vendor_id_2 = :vendor_id_2) 
            AND profile_id = :profile_id) 
        ORDER BY business_name ASC");
    $sqlQueryVendorId->execute(array(
        ':vendor_id_1' => $vendorId, 
        ':vendor_id_2' => $vendorId, 
        'profile_id' => $profileId));
    $sqlResultVendorId = $sqlQueryVendorId->fetch();

while ($sqlResultVendorId = $sqlQueryVendorId->fetch()){
    //Get values from table
    $businessNameDB = $sqlResultVendorId['business_name'];
    echo $businessNameDB;
}

出于某种原因,即使我多次尝试,列表也不按字母顺序排序。我不确定是什么问题。就像ORDER BY business_name ASC被忽略一样

我的清单如下:

Mary's Lamb
Bouncy Castles
Ping Pong Ball

我希望它按如下方式排序:

Bouncy Castles
Mary's Lamb
Ping Pong Ball

0 个答案:

没有答案