简体   繁体   English

mysql_query 中 SELECT 之后的 INSERT 语句

[英]INSERT Statement after a SELECT in mysql_query

I'm trying to execute two SQL statements in one mysql_query.我正在尝试在一个 mysql_query 中执行两个 SQL 语句。

$mySql = mysql_query("SELECT itemid, points FROM items WHERE id='1' UPDATE accounts SET userpoints = '1000'");

Is this possible?这可能吗? Thanks!谢谢!

You can only execute one query in mysql_query (even if you seperate the queries with the semicolon terminator).您只能在mysql_query中执行一个查询(即使您使用分号终止符分隔查询)。

You have to call them seperately (although this guy has a method to automate that).您必须单独调用它们(尽管这家伙有一种方法可以自动化)。

If you use mysqli you can use mysqli_multi_query()如果你使用 mysqli 你可以使用mysqli_multi_query()

I wouldn't try doing that since you won't be able to exploit the results from the different queries (returned values, mysql_insert_id(), ...)我不会尝试这样做,因为您将无法利用不同查询的结果(返回值、mysql_insert_id()、...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM