I wnat to build this select query but i'm reallt stumped with it:
I want to compare rows from different tables or rows form the same table.
what i have is the base table with the proper id and i need to get every single row from that i.e. SELECT * FROM table WHERE id='$id'
Thats easy ,but I need to compare rows form different tables or the same table but different id that has the same specific field value
example:
base table
id field other fields
-- ----- -----------
1 rr
1 pp
1 cc
1 ff
2 rr
2 pp
other table(s)
id field other fields
-- ----- ------------
3 rr
3 ii
4 pp
4 cc
What i need is first select all the rows from base table where id=1 and the rows from the same tables that has that specific field value like the base has e.g. from base table get the rows :rr,pp at the same line as they base
and on othe table get the rows (rr,pp,cc)
so the result will be:
Code: Select all
field(from base) id=2 id=3 id=4
----------------- --- ---- --- -----
rr exists(show all fields) exists(show all fields) missing
pp exists(show all fields) missing exists(show)
cc missing missing exists(show)
ff missing missing missing
?>Thank u all