How to use strcmp in if statement in mysql? -


i have compare 2 string , process based on result of strcmp in sql.

sample:

set @login='usc00010'; set @user='usc00010'; select strcmp(@login,@user);//returns 0 if(strcmp(@login,@user)= 0) //process1 else //process2 end if; 

and above code throws have error in sql syntax; check manual corresponds mysql server version right syntax use near 'if(strcmp(@login,@user)= 0)

actual requirement:

if(//matches) begin if exists(select x x )  begin if exists(select x x y=a) begin  update x                    end end else//doesn't match begin  //process2                       end 

set @login='usc00010'; set @user='usc00010'; select if(strcmp(@login,@user)= 0,"match","no-match") str_compare 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -