mysql - select within if add block code -


i have selection , wanted search column of table left join if user enabled pre condition essar search condition adds tables little confused, not know if separate searches or @ once .... says it's me @ mysql system, see so

if .condition... ... end if;  

my code

select user. * u user if (u.visible == 1,    left join houseuser hu on u.id = h.id_user    left join h house on hu.id_house = h.id_house ) u.age> 30 

if visible add code can see in house user is.

you can incorporate condition on clauses:

select u.*, hu.*, h.* user u left join      houseuser hu      on u.id = h.id_user , u.visible = 1 left join      h house      on hu.id_house = h.id_house , u.visible = 1 u.age > 30; 

the columns come back, null when visible not 1.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -