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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left join problem when columns have same name 1

Status
Not open for further replies.

JoSno

Programmer
Apr 11, 2003
45
GB
I'm having a bit of bother. I have two tables, one is called da7hdr and contains the main details for what I'm doing.

I then have a table called da7hdrd which relates to da7hdr by each of its records having a value called hdr_key which references the da7hdr.hdr_key (so it's a foreign key if you like)

Now, these two tables should contain the exact same amount of records but they dont so I want to see which records in da7hdr dont have a corresponding value in da7hdrd. So I thought the simplest thing would be to do a left join on da7hdr, da7hdrd where da7hdr.hdr_key = da7hdrd.hdr_key but it just hangs.

I believe this to be because the two tables contain the identically named field 'hdr_key'. I have searched the web and seen ideas with USING but it still just hangs when I try them out. The simplest option would be to rename the hdr_key field in da7hdrd but I just dont want this thing to beat me, any ideas?

Jo
 
when you say "do a left join on da7hdr, da7hdrd where da7hdr.hdr_key = da7hdrd.hdr_key" what exactly does the sql look like?

it should be

[tt] from da7hdr
left outer
join da7hdrd
on da7hdr.hdr_key = da7hdrd.hdr_key[/tt]

rudy
 
Rudy mate I'm so sorry, it turns out I was just being impatient. It only had to come up with 4002 results so I thought it would be quick but of course it was searching so many more than that. Anyway I had put it like you said so you can have a tick anyway!

Jo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top