dc_jt Posted May 17, 2007 Share Posted May 17, 2007 Hi I have a table like the following: offer_id name ordering 1 test 5 2 test 2 4 3 test 3 3 4 test 6 2 5 test 5 1 As I enter more, they go to the top so the next one would have ordering 6. How do I find the first four? ( test, test2, test3 and test 4) I.e The latest ones added? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/51792-finding-first-four-in-list/ Share on other sites More sharing options...
neel_basu Posted May 17, 2007 Share Posted May 17, 2007 SQL : select `name` from `table_name` order by `offer_id` ASC limit 4 Quote Link to comment https://forums.phpfreaks.com/topic/51792-finding-first-four-in-list/#findComment-255183 Share on other sites More sharing options...
jitesh Posted May 17, 2007 Share Posted May 17, 2007 select * from table order by ordering DESC limit 0,4 Quote Link to comment https://forums.phpfreaks.com/topic/51792-finding-first-four-in-list/#findComment-255184 Share on other sites More sharing options...
jitesh Posted May 17, 2007 Share Posted May 17, 2007 If offer_id is primary key and auto incremented then select * from table order by `offer_id` DESC limit 0,4 Quote Link to comment https://forums.phpfreaks.com/topic/51792-finding-first-four-in-list/#findComment-255190 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.