* Eric Mayers > I have three tables, each with a single column, "data". > > I'd like to form a query that will combine the table columns into a > common result column. > > When I use the query: "SELECT * from tab1, tab2, tab3" I get: > > +-------------+------------+-----------+ > | data | data | data | > +-------------+------------+-----------+ > | VAL1 | VAL2 | VAL3 | > +-------------+------------+-----------+ > > But what I want is: > > +-------------+ > | data | > +-------------+ > | VAL1 | > | VAL2 | > | VAL3 | > +-------------+ > > > Is this possible?
Yes, it is possible. Use a temporary table and multiple statements: mysql> create temporary table tmp1 select * from tab1; Query OK, 1 row affected (0.40 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into tmp1 select * from tab2; Query OK, 1 row affected (0.02 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into tmp1 select * from tab3; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from tmp1; +------+ | data | +------+ | VAL1 | | VAL2 | | VAL3 | +------+ 3 rows in set (0.01 sec) mysql> Sometimes it is also possible to do this with a single statement using LEFT JOIN and the IF() function. -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php