re: combine data from two tables

2002-12-14 Thread Egor Egorov
On Thursday 12 December 2002 20:35, Mark Goodge wrote:

 I'm hoping that someone can give me some pointers on this problem. I have
 two tables that contain similar data (eg, people.employees and
 people.volunteers). I need to run a select statement to retrieve names from
 both tables, and then display the data sorted by name so that it doesn't
 matter which table it came from.

 For example, if people.employees contains Amy, Charles and Eric, while
 people.volunteers contains Brian, David and Fred, then the resulting output
 needs to be displayed in this order:

 Amy
 Brian
 Charles
 David
 Eric
 Fred

 I could do this by post-processing the data in the script which retrieves
 it, but I'd prefer to get it in the correct order direct from MySQL. Any
 suggestions?

You can do it with UNION in 4.0.x:

http://www.mysql.com/doc/en/UNION.html

or with TEMPORARY tables in 3.23.xx



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




-
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




combine data from two tables

2002-12-12 Thread Mark Goodge
Hi,

I'm hoping that someone can give me some pointers on this problem. I have 
two tables that contain similar data (eg, people.employees and 
people.volunteers). I need to run a select statement to retrieve names from 
both tables, and then display the data sorted by name so that it doesn't 
matter which table it came from.

For example, if people.employees contains Amy, Charles and Eric, while 
people.volunteers contains Brian, David and Fred, then the resulting output 
needs to be displayed in this order:

Amy
Brian
Charles
David
Eric
Fred

I could do this by post-processing the data in the script which retrieves 
it, but I'd prefer to get it in the correct order direct from MySQL. Any 
suggestions?

Thanks

Mark


-
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