TheEvilMonkeyMan Posted November 22, 2010 Share Posted November 22, 2010 Hey, I'm having trouble with this query that's supposed to left join an 'answer' row to a 'question' row but I keep getting "Unknown column q.id in 'on clause'". Here's the query: SELECT * FROM questions_new AS q, questions_map_domains AS map LEFT JOIN answers AS ans ON (ans.question_id = q.id) WHERE q.id = map.question_id AND map.domain_id = $domain_id Quote Link to comment https://forums.phpfreaks.com/topic/219437-left-join-trouble/ Share on other sites More sharing options...
Muddy_Funster Posted November 22, 2010 Share Posted November 22, 2010 Could you please post a dump of your table structures? Quote Link to comment https://forums.phpfreaks.com/topic/219437-left-join-trouble/#findComment-1138089 Share on other sites More sharing options...
TheEvilMonkeyMan Posted November 23, 2010 Author Share Posted November 23, 2010 Ah, I fixed it! Thanks for your reply SELECT q.*, ans.content AS answer FROM questions_map_domains AS map, questions_new AS q LEFT JOIN answers AS ans ON (ans.question_id = q.id) WHERE q.id = map.question_id AND map.domain_id = $domain_id AND q.down_votes < 3 ORDER BY q.up_votes DESC, q.down_votes ASC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/219437-left-join-trouble/#findComment-1138280 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.