PDA

View Full Version : how to contruct this sql statement


verybrightstar
06-18-2003, 04:11 AM
Hi,
i have this table

Country Table

countrycode | countryname
---------------------------------
100 | USA
200 | England
300 | China
400 | Hong Kong
500 | Taiwan

SELECT countrycode,countryname from Country
WHERE countryname IN ('China,'USA','Hong Kong')

i will get

100 | USA
300 | China
400 | Hong Kong


how can i get the results that arrange according to the selected country i want from China , USA , Hong kong

300 | China
100 | USA
400 | Hong Kong

how to i build this sql query?

Strike
06-18-2003, 09:51 AM
I'm not sure I understand the question. In what ordering scheme is "USA" after "China" but before "Hong Kong"? You can't order by the order in the IN statement as far as I know. You can only order on the columns in the tables in your database. If this means that you have to stick another column in there named "sort_order" or something, then that's what you have to do.

gish
06-18-2003, 11:25 AM
Originally posted by Strike "sort_order" or something, then that's what you have to do.

that is what I would do as well...