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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -