OK, here's my situation...I have three tables. Each of them have a field called name, position, and email. l want to write a query thta will list the names from the 3 tables, the positions from the three tables, and the email from the three tables. I want to do this with 3 columns. It seems like something thta can be done but I'm drawing a blank. So...
column 1 - names from the three tables
column 2 - positions from the 3 tables
column 3 - email from the three tables
any ideas? Thanks in advance.
MySql question
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Am I right in thinking that you want something along the lines of:
Mac
Code: Select all
name1 | position1 | email1
name2 | position2 | email2
name3 | position3 | email3
name4 | position4 | email4
name5 | position5 | email5
etc...- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Use temp tables to hold the data. This page from the MyQL manual explains how to select data from one or more tables and hold the results in a new temp table. This should do what your looking for.
http://www.mysql.com/doc/en/INSERT_SELECT.html
Keith
http://www.mysql.com/doc/en/INSERT_SELECT.html
Keith
You could also use the UNION operator if you're using at least MySQL 4.0:
Code: Select all
select name, position, email
from table1
UNION
select name, position, email
from table2
UNION
select name, position, email
from table3