RyanA
RyanA

Reputation:

INSERT Statement after a SELECT in mysql_query

I'm trying to execute two SQL statements in one mysql_query.

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

Is this possible? Thanks!

Upvotes: 1

Views: 381

Answers (3)

Tom Haigh
Tom Haigh

Reputation: 57825

If you use mysqli you can use mysqli_multi_query()

Upvotes: 2

Gad
Gad

Reputation: 42306

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(), ...)

Upvotes: 0

Ross
Ross

Reputation: 47057

You can only execute one query in mysql_query (even if you seperate the queries with the semicolon terminator).

You have to call them seperately (although this guy has a method to automate that).

Upvotes: 3

Related Questions