attaboy Posted March 9, 2012 Share Posted March 9, 2012 I have a table called inventory mysql> SELECT * FROM inventory; +------------+--------------------+--------+-----+ | make | model | price | mpg | +------------+--------------------+--------+-----+ | Ford | Model T | 22500 | 17 | | Studebaker | Hawk | 17500 | 20 | | Volkswagen | Bug | 19900 | 25 | | Ace | Continental | 33900 | 12 | | Lincoln | Continental | 33900 | 10 | | Ford | Model A | 33995 | 18 | | Packard | Series 1604 | 112700 | 15 | | AMC | AMX | 26995 | 21 | | Nash | Airflyte Statesman | 1500 | 13 | | Lincoln | Zephyr | 1800 | 12 | +------------+--------------------+--------+-----+ I need to order by make and model. I tried this: mysql> SELECT make, model, price -> FROM inventory -> WHERE make IN -> ( -> SELECT make -> FROM inventory -> ORDER BY model -> ) -> ORDER BY make; and this was the result, it's ordered by make but I need it to be ordered model under make so that Ford Model A comes before Ford Model T +------------+--------------------+--------+ | make | model | price | +------------+--------------------+--------+ | Ace | Continental | 33900 | | AMC | AMX | 26995 | | Ford | Model T | 22500 | | Ford | Model A | 33995 | | Lincoln | Continental | 33900 | | Lincoln | Zephyr | 1800 | | Nash | Airflyte Statesman | 1500 | | Packard | Series 1604 | 112700 | | Studebaker | Hawk | 17500 | | Volkswagen | Bug | 19900 | +------------+--------------------+--------+ Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 9, 2012 Share Posted March 9, 2012 ORDER BY make, model Quote Link to comment Share on other sites More sharing options...
attaboy Posted March 9, 2012 Author Share Posted March 9, 2012 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.