MYSQL: Concat two tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

MYSQL: Concat two tables

Post by lauthiamkok »

Hi,
I have two tables, for instance,

Table 1
======

id_1 / title_1 / date_1
-------------------------
1 / A / xxx
2 / B / xxx


Table 2
======

id_2 / title_2 / date_2
-------------------------
1 / C / xxx
2 / D / xxx



How can make make the query so that I can have this result that it is i sorted by date,

id / title / date
-------------------------
1 / A / xxx
2 / C / xxx
1 / B / xxx
2 / D / xxx

Is it possible?

I tried to JOIN or to LEFT JOIN them, but it won't get the result I am looking for, is there any other SQL syntax I can try??

Many thanks,
Lau
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MYSQL: Concat two tables

Post by requinix »

Why do you have two tables?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: MYSQL: Concat two tables

Post by AbraCadaver »

mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

Re: MYSQL: Concat two tables

Post by lauthiamkok »

thanks for the reply. yes - union - is what i need.

sorry for not replying you guys earlier cos was not notified.

thanks! :D
Post Reply