On Fri, 30 Jul 2004 23:25:57 -0400, Chris Payne <[EMAIL PROTECTED]> wrote: > Hi there everyone, > > I'm new to JOINS and have followed some info in the MySQL manual but I'm at > a loss, using the code I'll paste below, I get each result 4 times and I am > confused as to why? Basically I'm trying to display ALL fields from the > vendorprices table, and grab just the Description column from the fooditems > table, the factor which joins them both is the string $VendorID which in the > vendorprices table is VendorNumber and in the fooditems table is > CategoryNumber. > > $sql = "SELECT * FROM vendorprices LEFT JOIN fooditems on > (vendorprices.VendorNumber = fooditems.CategoryNumber AND > fooditems.CategoryNumber = '$VendorID') WHERE > vendorprices.VendorNumber='$VendorID' AND > fooditems.CategoryNumber='$VendorID'"; > > Can anyone see where I'm going wrong? This is driving me nuts and I need to > figure it out urgently. >
You should / can only join ON columns. You're putting "fooditems.CategoryNumber='$VendorID'" twice, you only need / should have it in the WHERE clause. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php