The following query returns the expected result when I use the SQL input box in PHPMyAdmin, however in a PHP MySQLi query ($sql->query()
) an error occurs.
SET @a = 5;
SET @b = (SELECT `b` FROM `t` WHERE `c`=@a);
SELECT @b;
The error I get is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @b= (SELECT b
FROM `t' at line 2
You are doing 3 queries instead of 1 so you would need multi_query()
instead of query()
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments