Link to home
Start Free TrialLog in
Avatar of jamiepryer
jamiepryerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL - Select From Left join & where

hi,
im trying to select some data from 2 tables, where i left join the info in table2, where t2.name = "x"

so ive got the following but it just doesnt work?

select t1.ent, t2.priv
from file.csv t1
left join file2.csv t2
on t1.ent = t2.ent
where t2.app = 'x'

it does all work until i add in the final where clause and then the results are empty
but i know that t2.app = "x" does exist
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

this shall work:
select t1.ent, t2.priv
from file.csv t1
left join file2.csv t2
on t1.ent = t2.ent
AND t2.app = 'x'

Open in new window

What is the result of this query ?
select t1.ent, t2.priv
from file2.csv t2
left join file.csv t1
on t1.ent = t2.ent
where t2.app = 'x'
Avatar of jamiepryer

ASKER

Angel - didn't work with the and

Raj - gives null resuts as I think the where is being applied to the whole query, not just the above join statement
>> Angel - didn't work with the and

What do you mean by not working? Can you post the result of that query and expected result?
ASKER CERTIFIED SOLUTION
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India 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
thanks
Glad to help you
Raj