For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > July 2007 > Friday losing it: JOINS









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Friday losing it: JOINS
Instruct ICC

2007-07-20, 6:59 pm

I have a 1 table query which returns less rows than when I have a 2 table
query using an implicit inner join or an explicit left join.

Select some, fields
From table1
Where part like '123%'
/* returns 2225 rows */

Select activePart, some, fields
From table1, table2
Where part like '123%'
and part = activePart
/* implicit inner join returns 2270 rows */

Select activePart, some, fields
From table1 left join table2
On part = activePart
Where part like '123%'
/* explicit left join also returns 2270 rows */

Fields part and activePart are not in table2 and table1 respectively.

I assume I am forgetting something basic this friday. Why would I get more
rows from the above? I might expect more rows from an outer join. Am I
writing an outer join?

After a quick break in the john, I'm thinking perhaps table2 is not holding
unique "part"s as I was told it would. But I'll post this for your thoughts
before I check on that, in case you have other insights.

________________________________________
_________________________
http://imagine-windowslive.com/hotm..._2G_0507

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com