Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Help with query (WHERE clause)

I have a select statement, but I think the WHERE clause is incorrect. This is my current code:

Select *  
FROM   Cases AS c
       LEFT JOIN Users e ON e.UserId = c.AlienId
LEFT JOIN dbo.Employment AS g ON g.UserId = c.AlienId
WHERE  c.Id = @caseid AND g.CurEmp = 1; 

Open in new window


In reality what I need is to get the g.CurEmp=1  inside the left join dbo.Employment

In other words, the left join should be to that table HERE CurEmp=1
and the final WHERE clause should only read c.Id = @caseid

How can I do this?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aleks

ASKER

Looks good thanks. I just moved the  ;  to the end of the query