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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -