Jump to content

Problem with Left Join using PHP


akashranjan

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.