PDA

View Full Version : SQL Listing



NathanZachary
October 6th, 2007, 10:29 AM
Hello World :)

Im making an article listing script with php and MySQL.

Articles get submitted to SQL database, and now I want to make an overview over the 4 most recently submitted.

The question is, is that possible? And in that case, what hints can you lend me? :)

Also, is there any possibility for the SQL to return the entry which has the highest ID?

NathanZachary

Charleh
October 6th, 2007, 12:12 PM
Yes and yes

Hints, look in PHP manual at MySQL functions

Learn T-SQL, (transact SQL), use the ORDER BY clause, and TOP clause or LIMIT clause

i.e.

SELECT TOP 1 * FROM Articles ORDER BY ID DESC

blazes
October 6th, 2007, 03:28 PM
Something like:


SELECT * FROM articles ORDER BY id DESC LIMIT 4

NathanZachary
October 9th, 2007, 01:23 PM
Something like:


SELECT * FROM articles ORDER BY id DESC LIMIT 4

Perfect :) Thank you :)