Friday losing it: JOINS
| From: | Instruct ICC | Date: | Fri, 20 Jul 2007 17:03:22 +0000 |
| Subject: | Friday losing it: JOINS | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-43823@lists.php.net to get a copy of this message | ||
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/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507