c_pattle Posted January 19, 2011 Share Posted January 19, 2011 I have the follow sql which uses "union" to combine to select statements. However when I run this it gives me all of the results of the first statement follow by all of the results of the second statement. I was wondering if there is a way to make it output 1 results from the first statement then one results from the second statement then the second results from the first statement etc SELECT * FROM articles WHERE article_verification="1" limit 0,10 UNION (SELECT * FROM announcements WHERE announcement_verification="1" limit 0, 10); Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/225007-mysql-union-help/ Share on other sites More sharing options...
c_pattle Posted January 19, 2011 Author Share Posted January 19, 2011 Actually sorry forget that. What I want to do is to have a mysql query that will combine a row from two tables into one. For example say I have the follow tables, articles: 1 - article 1 2 - article 2 3 - article 3 announcements: 1 - announcement 1 2 - announcement 2 3 - announcement 3 4 - announcement 4 What I want to do is to have a statement that will return the first row of both tables. I think the best thing to do is a select statement but mine isn't quite working right. select articles.article_title, announcements.announcement_title from articles, announcements order by article_number desc limit 0,10 Quote Link to comment https://forums.phpfreaks.com/topic/225007-mysql-union-help/#findComment-1162172 Share on other sites More sharing options...
Muddy_Funster Posted January 20, 2011 Share Posted January 20, 2011 If you want the article and announcement to match up with each other you will need to join them on a common field type. A sample dataset and your table structues would be a big help to us. Quote Link to comment https://forums.phpfreaks.com/topic/225007-mysql-union-help/#findComment-1162391 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.