| | |
ORDER BY
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2008
Posts: 73
Reputation:
Solved Threads: 1
Hello all,
I have the following SQL statement.
I want to sort by a.airport_name but every time I add ORDER BY a.airport_name ASC to the end of this query, it fails to load the page. Is there an issue with adding and ORDER BY to the end of this statement or should it go somewhere else in it?
Thanks
Dave
I have the following SQL statement.
MySQL Syntax (Toggle Plain Text)
SELECT a.airport_code AS AIRPORTCODE, a.airport_name AS AIRPORT, u.usr_id AS USERID, u.usr_fname AS FIRSTNAME, u.usr_lname AS LASTNAME, u.usr_email AS EMAIL,u.usr_airline AS AIRLINE, u.usr_airline_iatacode AS IATA, t.title AS TITLE FROM users u LEFT JOIN userairportservices uas ON uas.usr_id_users = u.usr_id LEFT JOIN airport a ON a.airport_id = uas.airport_id_airport LEFT JOIN title t ON t.title_id = u.usr_title WHERE a.airport_code= apcode
I want to sort by a.airport_name but every time I add ORDER BY a.airport_name ASC to the end of this query, it fails to load the page. Is there an issue with adding and ORDER BY to the end of this statement or should it go somewhere else in it?
Thanks
Dave
Last edited by filch; Sep 25th, 2009 at 1:49 am.
try
sql Syntax (Toggle Plain Text)
SELECT a.airport_code AS airportcode, a.airport_name as airport, u.usr_id as userid, u.usr_fname as firstname, u.usr_lname as lastname, u.usr_email as email,u.usr_airline as airline, u.usr_airline_iatacode as iata, t.title as title FROM users u LEFT JOIN userairportservices uas on uas.usr_id_users = u.usr_id LEFT JOIN airport a on a.airport_id = uas.airport_id_airport LEFT JOIN title t on t.title_id = u.usr_title WHERE airportcode = '%s' ORDER BY airport asc, $apcode
Last edited by almostbob; Sep 25th, 2009 at 9:45 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Nov 2008
Posts: 73
Reputation:
Solved Threads: 1
•
•
•
•
trysql Syntax (Toggle Plain Text)
SELECT a.airport_code AS airportcode, a.airport_name as airport, u.usr_id as userid, u.usr_fname as firstname, u.usr_lname as lastname, u.usr_email as email,u.usr_airline as airline, u.usr_airline_iatacode as iata, t.title as title FROM users u LEFT JOIN userairportservices uas on uas.usr_id_users = u.usr_id LEFT JOIN airport a on a.airport_id = uas.airport_id_airport LEFT JOIN title t on t.title_id = u.usr_title WHERE airportcode = '%s' ORDER BY airport asc, $apcode
Thanks for your help
![]() |
Similar Threads
- [B]What changes need to be made to the above database definition in order to solve al (Visual Basic 4 / 5 / 6)
- Listing Integers in Numerical Order (C)
- Sorting Not In Order (C)
- names in ascending order problem (C++)
- Changing Startup Programs Order (Windows NT / 2000 / XP)
- DOS C++, pulling boot order and hard drive parameters, (C++)
Other Threads in the MySQL Forum
- Previous Thread: PostGreSQL: Optimizing a function with CASE syntax... Help please
- Next Thread: MySQL select to return most recent record
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm data database design developer development distinct drupal dui ec2 email enter eudora facebook form foss gartner gnu government greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






