mysql - Exclude left join in case of empty cells -
so need join company table in case email field populated.
is there way exclude company table join in case there empty email field?
select * person p left join company c on(substring_index(p.email, '@', -1)=c.website , p.email <> '')
i can't "where" clause because joining yet table, , want table joined regardless.
any appreciated, thanks!
i figured out! flash of inspiration, and...
select * person p left join company c on((case when length(p.email)>0 substring_index(p.email,'@',-1) else "purplepower" end)=c.website)
by using "case" clause have made sure email values exist matched. if not, matching arbitrary string of course doesn't match company table.
Comments
Post a Comment