iwanalearn
Technical User
I have a database that searches for dealers based on the zip code entered. I want the results to show the dealers with the same zip code on top of the list then alphabetical after that. We have switched from mysql to mssql. Learning mssql but need help converting this code.
This is how I sorted the results in mysql.
$result = mysql_query
("SELECT * FROM zipcodes, dealers
WHERE zipcodes.Start <='$zip' and zipcodes.Stop >='$zip'
and dealers.DealerID=zipcodes.DealerId
ORDER BY dealers.Zip='$zip'DESC, dealers.DealerName ASC
LIMIT 10");
This is where I am with the mssql.
$result = mssql_query
("SELECT TOP 10 * FROM zipcodes, dealers
WHERE zipcodes.Start <='$zip' and zipcodes.Stop >='$zip'
and dealers.DealerID=zipcodes.DealerId
order by dealers.DealerName ASC");
This is how I sorted the results in mysql.
$result = mysql_query
("SELECT * FROM zipcodes, dealers
WHERE zipcodes.Start <='$zip' and zipcodes.Stop >='$zip'
and dealers.DealerID=zipcodes.DealerId
ORDER BY dealers.Zip='$zip'DESC, dealers.DealerName ASC
LIMIT 10");
This is where I am with the mssql.
$result = mssql_query
("SELECT TOP 10 * FROM zipcodes, dealers
WHERE zipcodes.Start <='$zip' and zipcodes.Stop >='$zip'
and dealers.DealerID=zipcodes.DealerId
order by dealers.DealerName ASC");