joining table and sort it
Hi
I'm facing a problem. I want to join two table which are in the following format.
Table 1
id - - name
1 - - xx
2 - - yy
3 - - zxz
Table 2
id -- xx -- yy
1 -- 1 -- 1
2 -- 2 -- 1
3 -- 1 -- 2
I want make a query which can get join two tables based on the value given by the user in the column yy in the second table. For example, I will expect the wuery to return the following table if I search for '1' in column yy (table 2)
result table
c_id -- name -- xx -- yy
1 -- xx -- 1 -- 1
2 -- yy -- 2 -- 1
3 -- zxz
I want the entire rows in the table 1 with the values what I search for in the table 2. IF the search value is not there in table 2 then the result table for that paticular id should be empty.
I tried to write
select * from table 1 left join table 2 using (id) where yy =1
It is working good but not able to return the rows from table1 which doesn't have the value yy =1.
I hope it a bit clear.
Any help would be great.
thanks
Subject
Written By
Posted
joining table and sort it
September 20, 2011 05:47AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.