On Thu, Oct 1, 2009 at 4:03 PM, Gavin Towey <gto...@ffn.com> wrote: > Joins aren't nested like that, unless you use a subquery. I think you just > need to remove the parens around the second join. >
I tried that and no go :( > > For better help: > 1. show the real SQL -- echo the statement. Most people here don't like > looking at app code because your variables could contain anything. > > ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') left join categories on products.Category=categories.ID)' at line 1"), referer: http://13gems.com/global_solutions/spreadsheet_edit.py 2. Give the exact error message > > Isn't that the same thing? > 3. If there's no error, explain what you expect and what you're getting > > 4. Include table schema > > DESCRIBE `ben_franklin_planners` ID int(4) unsigned NULL Item int(4) unsigned NULL Discount int(2) unsigned NULL DESCRIBE categories ID int(3) primary key not NULL auto_increment Category varchar(20) unique NULL describe products ID int(4) primary key not NULL Category int(3) NULL Item varchar(20) UNIQUE NULL Description varchar(255) NULL UOM varchar(20) NULL Price float(7,2) NULL > 5. Explain what you're trying to accomplish. > > cursor.execute('select * from %s left join products on %s.Item=products.Item left join categories on products.Category=categories.ID;' % (client, client)) The "client" in this case is ben_franklin_planners ben_franklin_planners has an item # that is the same as the item # in products, where all the information about the products is to be found, EXCEPT the name of the category. For that, we have to go to the categories table. Hope that makes it clear. TIA, V