I have the following code:
$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;
}
For some reason even though I tried many times the list is not sorted alphabetical. I'm not sure what is wrong. It is like ORDER BY business_name ASC
is being ignored
My list is as follows:
Mary's Lamb
Bouncy Castles
Ping Pong Ball
I want it to be sorted as follows:
Bouncy Castles
Mary's Lamb
Ping Pong Ball