I would like to know, how can we ordered the list using order by in MySQL.
below are the statement
SELECT info.* From p_all,resinfo
WHERE (p_all.id = info.id ) AND
p_all.id IN (21,10,42,84,234,15,251) AND
p_all.table_type = 'price' AND p_all.room_type='d' AND
p_all.year = '2012'
order by p_all.room_type='d'
Please provide me some information, how can we Order the room type (Price) according to Highest to Lowest.
info = stored id and hotel information.
p_all = month table with same id (info) having information of price (table_type), rooms (room_type), year (2012)
Ordering is easy, you simply list the fields you want to order by after the keywords ORDER BY. You don’t make it clear which column actually contains the price (you say
room_typeandtable_typein different places in your question) but assuming the price is in table_type you would use:(the DESC, standing for “descending” means the sort will be from highest to lowest).
You’ll also have to deal with the fact that you reference
infoas a table in your results but there is no such table included in the SELECT (probably you meantresinfo?).It would be helpful if you showed the original table structures and perhaps a few records from each.