rockinaway Posted January 19, 2007 Share Posted January 19, 2007 I am doing a join and it isn't working..[code]SELECT * FROM db_stuff AS c WHERE c.name = "stuff" LEFT JOIN db_stuff as f ON f.name = "litter" AND f.parent = c.id');[/code]Sorry had to change names... I get the following error:[quote]Unable to query database. The database server reported: 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 db_stuff as f ON[/quote] Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted January 19, 2007 Share Posted January 19, 2007 The LEFT JOIN has to go after the FROM. Also you have closing ') but no opening ( or '.[code]SELECT *FROM db_stuff AS c LEFT JOIN db_stuff as f ON (f.name = 'litter' AND f.parent = c.id)WHERE c.name = 'stuff'[/code] Quote Link to comment Share on other sites More sharing options...
rockinaway Posted January 19, 2007 Author Share Posted January 19, 2007 Hmm now nothing is listed.. and the ) is supposed to be there.. missed the start bracket ;) Quote Link to comment Share on other sites More sharing options...
rockinaway Posted January 19, 2007 Author Share Posted January 19, 2007 Sorry, just had to mention something. I need to check if the name = category first as then I want the results to be used for the join.. how can I do this? Quote Link to comment Share on other sites More sharing options...
micmania1 Posted January 19, 2007 Share Posted January 19, 2007 Why are you trying to join the same table? Quote Link to comment Share on other sites More sharing options...
rockinaway Posted January 19, 2007 Author Share Posted January 19, 2007 I need to.. there is no other way to group the names under their catgories... well which I have found.. the way I am currently doing it, it repeats the category for every name... however I just want one category with all names listed.. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 22, 2007 Share Posted January 22, 2007 [quote author=rockinaway link=topic=123163.msg508730#msg508730 date=1169231991]I need to.. there is no other way to group the names under their catgories... well which I have found.. the way I am currently doing it, it repeats the category for every name... however I just want one category with all names listed..[/quote]Sounds like a job for GROUP_CONCAAT(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.