I'm running this code in PHP:
mysql_query("SET @update_id:=NULL");
echo mysql_error();
And this is what I get:
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 '' at line 1
Also this same code runs perfectly in PHPMyAdmin. What am I doing wrong?
Additional information. I'm trying to write a query described here: How to get ID of the last updated row in MySQL? But the problem right now is that I even can't run a simple query to create variable.
PS Ok, now it seems that it desn't work because of some previous queries that are not related to this one. If i move this query to the top of the php file it works. Also if I try to make this:
mysql_query("SET @update_id:=NULL; SELECT @update_id;"); It fails with syntax error. But this works fine: mysql_query("SET @update_id:=NULL;"); mysql_query("SELECT @update_id;"); Does somebody knows what am I missing here? Why can't I run two commands in one query and why they're the separate queries are related to each other?
mysql_query("UPDATE your_table SET update_id=NULL");
检查这可能会有所帮助
SELECT @update_id IN("SET @update_id:=NULL");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.