all groups > sql server (alternate) > september 2007 >
You're in the

sql server (alternate)

group:

simple OUTER JOIN (I thought)


simple OUTER JOIN (I thought) tescodiscolondon NO[at]SPAM googlemail.com
9/11/2007 2:38:36 PM
sql server (alternate): Two tables:

Fruit
fruitID, fruitName

Basket
buyerID, fruitID

(ie. we can see which buyer has what fruit in their basket)

I simply want to display all available fruit and whether or not it's
in a specific persons' basket.

SELECT Fruit.fruitID, Fruit.fruitName, IsNull(buyerID, 0)
FROM Fruit INNER JOIN Basket ON Fruit.fruitID = Basket.fruitID
WHERE Basket.buyerID = 12

but this just gives me what's in buyer 12s' basket.

What am I doing wrong? Am I a basket case...
Re: simple OUTER JOIN (I thought) tescodiscolondon NO[at]SPAM googlemail.com
9/11/2007 3:28:02 PM
Ah yes, never put your criteria into a WHERE clause.

SELECT Fruit.fruitID, Fruit.fruitName, IsNull(buyerID, 0)
FROM Fruit INNER JOIN Basket ON Fruit.fruitID = Basket.fruitID AND
Basket.buyerID = 12

gives me what I wanted.

Forget this post.

[quoted text, click to view]

Re: simple OUTER JOIN (I thought) Ed Murphy
9/12/2007 7:44:36 PM
[quoted text, click to view]
AddThis Social Bookmark Button