Bladescope Posted April 13, 2009 Share Posted April 13, 2009 Afternoon again PHPFreaks, i've been wondering if it's possible to select multiple rows (with different names and values) from different tables. I'm trying to create a "Latest Additions" script which shows the latest 5 additions. In a perfect world, the query would take the first 5 results, ordered by date (which all tables have) from the 4 tables. Now the names themselves are close, three are called "Title" while one is called "Name", so there's not really any reason to why I can't rename the odd one out to follow suit. Server version: 5.0.45 Any help would be greatly appreciated! -Sean Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 13, 2009 Share Posted April 13, 2009 Read about UNION http://dev.mysql.com/doc/refman/5.0/en/union.html I think we even have a tutorial for that on www.phpfreaks.com Quote Link to comment Share on other sites More sharing options...
Maq Posted April 13, 2009 Share Posted April 13, 2009 I'm trying to create a "Latest Additions" script which shows the latest 5 additions. In a perfect world, the query would take the first 5 results, ordered by date (which all tables have) from the 4 tables. You're going to have to use LEFT JOIN and ORDER BY date DESC to obtain the correct order. Now the names themselves are close, three are called "Title" while one is called "Name", Should not be a problem. When you JOIN tables you need to specify what table each column comes from anyway. But you can ALIAS table names to make things a lot easier. Good luck. Quote Link to comment Share on other sites More sharing options...
Bladescope Posted April 13, 2009 Author Share Posted April 13, 2009 Fantastic, Thanks for the help Quote Link to comment 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.