I have this code here:
SELECT c.Case_Code,COALESCE(c.case1, c.case2) AS case_def,aspm.UserId
FROM Cases AS c
LEFT JOIN aspnet_Membership AS aspm
ON c.case_def = aspm.userId
And well, since there is an Alias in the On clause, it won't recognize the case_def.
What i need to do is, i need to take the non null value between case1 and case2 and i need to Left Join it as i do in my query.
How do i do this? Thanks in advance.
SELECT c.Case_Code,COALESCE(c.case1, c.case2) AS case_def,aspm.UserId
FROM Cases AS c
LEFT JOIN aspnet_Membership AS aspm
ON COALESCE(c.case1, c.case2) = aspm.userId
You can't specify an alias
used in the select
clause elsewhere in the query. However, some dbms' do accept that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.