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:

  1. you have not correctly bracketed or conditions
  2. 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

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -