How does mysql execute multiple SQL statements at a time? & Lt ;? Php $ SQL & quot; SELECT @ a: idFROMcsdnorderbyidasclimit30, 1; SELECT @ B: idFROMcsdnorderbyidasclimit60, 1; SELECT * fromcsdnwhereid & gt; @ aand mysql?
$ SQL ="
SELECT @ a: = id FROM csdn order by id asc limit 30,1;
SELECT @ B: = id FROM csdn order by id asc limit 60, 1;
SELECT * from csdn where id> @ a and id <@ B;
";
$ Result = mysql_query ($ SQL );
While ($ rs = @ mysql_fetch_array ($ result, MYSQL_ASSOC) {// empty record
Echo"
". $ Rs ['name'];
}
?>
An empty record is returned.
Put the content in $ SQL in phpmyadmin and execute it correctly. Therefore, the SQL statement should be correct. it is estimated that there is a problem with the connection method.
How can I write it to display it? thank you!
------ Solution --------------------
Mysql_query does not support running multiple SQL statements at the same time. You need to separate the marker
Mysql_query ("SELECT @ a: = id FROM csdn order by id asc limit 30,1 ");
Mysql_query ("SELECT @ B: = id FROM csdn order by id asc limit 60, 1 ");
Mysql_query ("SELECT * from csdn where id> @ a and id <@ B ");