Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inner join on multiple columns

Status
Not open for further replies.

rmahajan

Technical User
Mar 4, 2003
1
US
Hello everyone!
I have 3 tables with the following attributes

Table A
ic_id
pc
login

table b
ic_id
pc
address

table c
ic_id
pc
he

I want to join all three on columns ic_id and pc

Here is my query

select a.ic_id, i.pc, login,address, he
from tablea a, tableb b, tablec c
where a.ic_id = b.ic_id
and b.ic_id = c.ic_id
and a.pc = b.pc
and b.pc = c.pc

Basically I want to convert the query
select a.ic_id, a/pc, login, address, he
from tablea a inner join tableb b on a.ic_id = b.ic_id and a.pc = b.pc inner join tablec c on b.ic_id = c.ic_id
and b.pc = c.pc

into Oracle syntax
However I am getting duplicate records for this query. I tried to change the joins to a.ic_id = b.ic_id and a.ic_id = c.ic_id and still got the same results.

Thanks in advance for your help.

 
Try to add DISTINCT clause. Though, if you have no duplicates in tables, they shouldn't appear in result set.

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top