If I've read your post correctly you want a JOIN:

SELECT table1.x, table1.y, table1.z
FROM table1
JOIN table2 ON table1.id = table2.id
WHERE table1.id='$id'

you can alias the tables so you don't need to keep typing in the full
table name like so:

SELECT t1.x, t1.y, t1.z
FROM table1 AS t1
JOIN table2 AS t2 ON t1.id = t2.id
WHERE t1.id='$id'


2008/11/3 Michael <[EMAIL PROTECTED]>:
>
> I have a table that I select from as follows
>
> SELECT x,y,z FROM table WHERE id='$id'
>
> I want to break this into 2 tables where 'id' is the 'primary' field and is
> identical on both tables.
>
> How can I SELECT the same x,y,z now from the 2 tables using 1 SQL statement?

-- 
Chris Hope
The Electric Toolbox Ltd

Email: [EMAIL PROTECTED]
Web: www.electrictoolbox.com
Phone: +64 9 522 9531
Mobile: +64 21 866 529

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to