At 01.01.2002 23:12, you wrote: >OK... let's say I have two tables. Let's say one is an inventory >table, a bunch of items. One of the fields is for the inventory >items that have been sold, and are keys to the second table, which >is a list of customers; names & addresses. > >So let's say I want to pull out all inventory items acquired in >a particular month. Some of them have been sold, some have not. >I want to list them all, and if they've been sold, the names of >the purchasers, if not, then just blank. > >Problem is, of course, when I construct something like > >SELECT Inventory.*, Customer.Name WHERE Inventory.PurchasedBy = Customer.ID >(etc) > >I get an ungodly mess for those items with no Customer.Name becasue >of the way the query is joined(I think that's the right terminology) >across the tables. > >Is there a way around that? This has got to be a pretty common >scenario. I've tried WHERE Inventory.PurchasedBy = Customer.ID OR >Inventory.PurchasedBy = 0, but that does not help. I think you should do more typing ;-) select a.name, a.partnr, b.name,b.adress from inventory a, customer b where b.purchasedby = a.id and a.purchasedby is NULL. (or a.purchased = ' ') depending how you set the default of purchasedby. HTH Oliver
--------------------------------------------------------------------- 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