sql - mysql query repeats results -
i have query. need select rows if logo empty or button empty or vanitylogo empty. seems working but, printing multiple rows same mid. how fix ?
select fmm.mid, fmm.name , fmn.mnname, fmm.button, fmm.logo, fmm.vanitylogo x fmm , y fmn fmm.`button` = '' or fmm.`button` = 'null' or fmm.`button` = 'none' or fmm.`logo` = '' or fmm.`logo` = 'null' or fmm.`logo` = 'none' or fmm.`vanitylogo` = '' or fmm.`vanitylogo` = 'null' or fmm.`vanitylogo` null , fmm.mid=fmn.nid , fmm.status='active' , fmm.xyz_status='active'
you have got 2 major problems query:
- you have not correctly bracketed
orconditions - you have no join condition between tables, leading "cross join"
try this:
select fmm.mid, fmm.name , fmn.mnname, fmm.button, fmm.logo, fmm.vanitylogo x fmm join y fmn on fmn.some_column = x.some_column -- fix (fmm.`button` in ('', 'null', 'none') or fmm.`logo` in ('', 'null', 'none') or fmm.`vanitylogo` in ('', 'null') or fmm.`vanitylogo` null) , fmm.mid=fmn.nid , fmm.status='active' , fmm.xyz_status='active' you must fill in "fix this": line appropriate column names
regarding ors, bundled in() condition, , bracketed lot.
Comments
Post a Comment