Re: [SQL] weird join producing too many rows

2012-09-12 Thread Gary Stainburn
Hi, Thanks for this. I did eventually discover the cause being other rows in the pieces_requests table that I hadn't thought about. The short answer to your second part is that I don't know why I did it that way. Presumably when I first wrote it there was a reason. Gary On Wednesday 12 Septe

Re: [SQL] weird join producing too many rows

2012-09-12 Thread Samuel Gendler
I'll admit I don't see any reason why you should get duplicate rows based on the data you've provided, but I am wondering why you are using the subquery instead of just 'where r.r_id = 5695' select p.p_id, r.pr_ind from pieces p join pieces_requests r on p.p_id = r.p_id where r.r_id = 5695 Though

[SQL] weird join producing too many rows

2012-09-12 Thread Gary Stainburn
I have a pieces table with p_id as primary key. I have a requests table with r_id as primary key. I have a pieces_requests table with (p_id, r_id) as primary key, and an indicator pr_ind reflecting the state of that relationship A single select of details from the pieces table based on an entry i