Jump to content

mysql union help


c_pattle

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/225007-mysql-union-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/225007-mysql-union-help/#findComment-1162172
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.