Home > database >  MYSQL temporary variables in writing IF statements
MYSQL temporary variables in writing IF statements

Time:09-25

Turn to the
 
The set @ openid1=(select openid from table1 where tel='13812345678');
Select @ openid1;

IF (@ openid1 is null) OR (@ openid1=' ') THEN
The set @ openid1=(select openid from table2 where tel='13812345678');
END the IF
Select @ openid1;


The above code will prompt error in
IF (@ openid1 is null) OR (@ openid1=' ') THEN
The set @ openid1=(select openid from table2 where tel='13812345678');
END the IF
Select @ openid1;
This paragraph, the haven't change to the

CodePudding user response:

Through the user's mobile phone number, get his openid, first read from the table1, if table1 don't, then read the table2, logic is very simple, but the grammar, don't know why I have been an error

CodePudding user response:

 
The SET @ openid1=(select openid from table1 where tel='13812345678');
SELECT @ openid1;

IF (@ openid1 is null) OR (@ openid1=' ') THEN
The set @ openid1=(select openid from table2 where tel='13812345678');
END IF;
Select @ openid1;

CodePudding user response:

END IF;
END the IF here to END with a semicolon

CodePudding user response:

Mobile phone reply, speculation should be such, if (o1 is null or o1=' ') then...
  • Related