I have two tables, 'items' and 'stuff'.

Items has a primary key of itemid. and looksmlike this

ItemID  other fields...

1       ...
2
3
4
5
6

Stuff contains something like this:

ItemID  type  info
1       0    blah blah
2       0    something
2       1    ...
3       1    ...

I want a query which returns all the items, and if it exists, the info field
from related 'stuff' of type 0.

So far I've got:

SELECT Items.ItemID, Stuff.info FROM Items LEFT OUT JOIN Stuff ON
Items.ItemID = Stuff.ItemID WHERE (type = 0 OR type = NULL);

This works if there are no Stuff records with a type other than 0, eg, the
last one in the example. The Query returns items 1,2,4,5, & 6, no 3.

How can I make a query which returns all items and type 0's info (if it
exists)?

ian


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to