namit 0 Light Poster 19 Years Ago I have a databse in mysql and am looking to select the last 5 values in the database and there contence. How would i do this. Will be using php to do this. Thanks There is an incramenting variable called Id and could use that if possible. mysql 0 0 Share Phaelax 52 Practically a Posting Shark 19 Years Ago I think this will work. I'm not positive if TOP is in MySQL. SELECT TOP 5 * FROM table ORDER BY id DESC (assuming 'id' is the primary key in the table) 0 0 Share paradox814 1 Posting Whiz 19 Years Ago you might also want to put LIMIT 5 on there at the very end to just retrieve the last 5 results 0 0 Share Share Facebook Twitter LinkedIn Reply to this topic Be a part of the DaniWeb community We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge. Sign Up — It's Free!
Phaelax 52 Practically a Posting Shark 19 Years Ago I think this will work. I'm not positive if TOP is in MySQL. SELECT TOP 5 * FROM table ORDER BY id DESC (assuming 'id' is the primary key in the table) 0 0 Share
paradox814 1 Posting Whiz 19 Years Ago you might also want to put LIMIT 5 on there at the very end to just retrieve the last 5 results 0 0 Share