akashranjan Posted August 27, 2009 Share Posted August 27, 2009 Hi I have 4 tables to search the data from 1. user 2. user_courses 3. user_spouse 4. user_children I have a form for searching a user on the following fields. 1. Name, Course Subscribed, Hobbies. If someone selects a hobby then the program must search for user's own hobby, user_spouse's hobby and user_children's hobby. The query I am writing is: Select * from user U LEFT JOIN user_children UCh ON UCh.mem_id = U.mem_id LEFT JOIN user_courses UC ON UC.mem_id = U.mem_id LEFT JOIN user_spouse US ON US.mem_id = U.mem_id WHERE 1 AND (U.firstname LIKE '%Yash%') AND (UC.course_id = 4) AND (U.hobbies = 1 OR UCh.child_hobbies = 1 OR US.spouse_hobbies = 1) But keep getting the error: Unknown column 'UCh.child_hobbies' in 'where clause'. I've checked repeatedly and the fieldname is correct. Not able to understand where the problem is Plz help Akash Quote Link to comment https://forums.phpfreaks.com/topic/172087-problem-with-left-join-using-php/ Share on other sites More sharing options...
suresh64633 Posted August 27, 2009 Share Posted August 27, 2009 Do you have 'UCh.child_hobbies' field in your 'user_children' table? if yes, than try to run the query without where clause and check. Quote Link to comment https://forums.phpfreaks.com/topic/172087-problem-with-left-join-using-php/#findComment-907345 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.