* Laszlo G. Szijarto
> I'm trying to run two tables with identical table structures into a single
> continuous resultset.  To simpify, I have one table with columns
> ID int and
> NAME varchar(32) and another table2 with columsn ID int and NAME
> varchar(32), and each table has 100 items.  How would I formulate an SQL
> query to return 200 items in a continuous resultset which would have rows
> 1-100 from table and 101-200 from table2 -- making it appear in the
> resultset as if these were one continuous 200-item table.

Mysql version 4 have UNION support:

SELECT * FROM table_a
  UNION
SELECT * FROM table_b;

The above is _one_ statement.

<URL: http://www.mysql.com/doc/U/N/UNION.html >

Note the use of parentheses when you need to ORDER the combined result.

Version 3.23.x does not support UNION, but you can achieve the same result
using a temporary table, and three statements:

CREATE TABLE tmp SELECT * FROM table_a;
INSERT INTO tmp SELECT * FROM table_b;
SELECT * FROM tmp ORDER BY ID;

--
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

Reply via email to