tags:

views:

90

answers:

3

Hi! 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!

+3  A: 

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

Ross
Also, the WHERE is missing in the UPDATE query.
R. Bemrose
A: 

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

m_oLogin
That's the main reason it doesn't work ;)
Ross
+2  A: 

If you use mysqli you can use mysqli_multi_query()

Tom Haigh
A better solution - if you're using PHP5 take advantage of MySQLi!
Ross