Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Query - Left join syntax 1

Status
Not open for further replies.

JPATX2

Technical User
Jun 8, 2004
3
Hi Everyone,
I've been starring at this for an hour and a half....does anyone see a problem with this query? Thanks!
Code:
$query_projects = "SELECT * FROM projects WHERE engineer = '$engineer' AND customer = '$customer' AND platform = '$platform' AND dtype = '$dtype' AND archived = '$archived' 
LEFT JOIN plife on projects.project_id = plife.project_id WHERE pstate = '$pstate' AND is_active = 'TRUE'";

It's complains about this part: LEFT JOIN plife on projects.project_id = plife.project_id WHERE pstate = '$pstate' AND is_active = 'TRUE'";

I had it working before...not sure why it's not working now.....
 
First of all, you'd be better off in the MySQL forum.
Anyway, if you are not using sub queries then there is just one WHERE clause per query.
The syntax is jumbled, the join should follow the FROM statement and the WHERE clause needs to be consolidated.
Code:
SELECT * from projects AS p LEFT JOIN plife AS pl on p.project_id = pl.project_id WHERE p.engineer = '$engineer' AND p.customer ='customer' .......etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top