List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 18 1999 12:49pm
Subject:Re: mysql does not support union?
View as plain text  
[Reply-To: MySQL mailing list <mysql@stripped>,
 as your question has nothing to do with PHP!]

On Sat, 1999-09-18 01:37:42 -0700, Bharadwaj Chitrapu wrote:
> I came to know mysql does not support union.
> I am I correct?

Yes, MySQL does not support UNION as yet.

> I want records from 3 tables.
> How to do this?

If the order of result rows doesn't matter, then just do three single
SELECTs.

If you need to sort all selected rows from all three tables by some
order, then a work-around is to use a temporary table:

With MySQL V3.23.x, this should work (untested):
   CREATE TEMPORARY TABLE tmp type=HEAP SELECT * FROM table1 WHERE ...;
   INSERT INTO tmp SELECT * FROM table2 WHERE ...;
   INSERT INTO tmp SELECT * FROM table3 WHERE ...;
   SELECT * FROM tmp ORDER BY ...;
   DROP TABLE tmp;

With earlier versions do it this way:
   CREATE TABLE tmp1234 ( ...appropriate column definitions... );
   INSERT INTO tmp1234 SELECT * FROM table1 WHERE ...;
   INSERT INTO tmp1234 SELECT * FROM table2 WHERE ...;
   INSERT INTO tmp1234 SELECT * FROM table3 WHERE ...;
   SELECT * FROM tmp1234 ORDER BY ...;
   DROP TABLE tmp1234;

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
mysql does not support union?bharadwaj chitrapu18 Sep
  • Re: mysql does not support union?Martin Ramsch18 Sep
  • Re: [PHP3] mysql does not support union?Venky21 Sep