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 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. 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
Archived
This topic is now archived and is closed to further replies.