1 (edited by StevenBullen 2006-07-27 16:20)

Topic: Problem with mixing results (mysql)

Ok... Here is an example of what I am after...

I have two tables...
TESTA and TESTB
which both have the following fields.
id
date
title
body
difference

Now I want to return the full results for both tables.... in date order.... but mix the results.

So for example.... I can get these results very easy...
Result a
id - date - title - body - difference
1 - 20/06/06 - This is title - This is the main body - testa
2 - 23/06/06 - This is title - This is the main body - testa
3 - 26/06/06 - This is title - This is the main body - testa

Result b
id - date - title - body - difference
1 - 20/06/06 - This is title - This is the main body - testb
2 - 22/06/06 - This is title - This is the main body - testb
3 - 25/06/06 - This is title - This is the main body - testb

Now this is the result I would like from the above data for example...
id - date - title - body - difference
1 - 20/06/06 - This is title - This is the main body - testa
1 - 20/06/06 - This is title - This is the main body - testb
2 - 22/06/06 - This is title - This is the main body - testb
2 - 23/06/06 - This is title - This is the main body - testa
3 - 25/06/06 - This is title - This is the main body - testb
3 - 26/06/06 - This is title - This is the main body - testa


Any ideas people?

It could be very easy to do... but have mind blank. wink

2 (edited by zaher 2006-07-28 21:40)

Re: Problem with mixing results (mysql)

Use "Union" keyword
http://dev.mysql.com/doc/refman/4.1/en/union.html

If your people come crazy, you will not need to your mind any more.

Re: Problem with mixing results (mysql)

Just use a regular mysql query ... "SELECT * FROM tablea, tableb ORDER BY date"  Since you are getting all the info anyways smile You can also sort ascending or decending ....

best,

Jan