Page 1 of 1

Date and now() function

Posted: Fri May 26, 2006 4:29 pm
by tommy1987
Hi, I want to have a recent posts panel on my site, this will get the most recent posts from 6 tables in a mysql database.
The dates have all been inserted in the same consistent way, with the now() function. Anyone have any suggestions as to how I should do this in SQL? I want to get the most recent one from each table so six in total.

Thanks in advance

Posted: Fri May 26, 2006 4:33 pm
by RobertGonzalez
Are you talking about a six table join or six queries from six tables?

Posted: Fri May 26, 2006 4:37 pm
by tommy1987
I will do six queries, one from each table im just looking for what the SQL would look like...
Will it be something like "SELECT title FROM users ORDER BY date LIMIT 1" would that do it?

Posted: Fri May 26, 2006 4:38 pm
by RobertGonzalez

Code: Select all

<?php $sql = "SELECT title FROM users ORDER BY date DESC LIMIT 0, 1"; ?>
This selects the most recent post in the table (by date).