aviddv1 Posted November 22, 2006 Share Posted November 22, 2006 Hey there,I've got two tables. One table is called 'Press' the other is called 'News'. Both tables have a datetime field. I want to query both tables and return the record with most recent datetime. Other than the datetime field none of the fields match.Thanks,ward Link to comment https://forums.phpfreaks.com/topic/28141-most-recent-date-from-two-tables/ Share on other sites More sharing options...
printf Posted November 22, 2006 Share Posted November 22, 2006 Something like...[code](SELECT * FROM News) UNION (SELECT * FROM Press) ORDER BY date_time_column_name DESC LIMIT 1;[/code]if the [b]date_time_column_name[/b] names are not the same, then comma separate them in the ORDER BY clause.printf Link to comment https://forums.phpfreaks.com/topic/28141-most-recent-date-from-two-tables/#findComment-128738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.