sql - How can I test an IF statement in MySQL? -
how can test if statement in mysql ? i need know, happens when query if statement , returns nothing (0 row selected) ? in other word, select query returns when no row selected? return null ? if yes, throw error? if ( null ) ... ? or in case statement of if won't execute? in reality, have code this: if ( select banned users id=new.user_id ) // stuff note: banned column contains either 0 or 1 . all want know, code safe when query doesn't return row? mean throw error or nothing happens (just if statement doesn't execute) ? noted wanted test myselft, don't know how can test if statement in mysql. example, wanted test code: begin if ( select banned users id=new.user_id ) select 'test'; endif; end but code above doesn't run. that's why i've asked question. an if statement can tested in context of mysql stored program (a procedure, function or trigger.) mysql doesn't support anonymous blocks...