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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.