Ive been reading about mysqli multi_query and couldnt find a way to do this (if its possible)
$db->multi_query("SELECT id FROM table WHERE session='1';
UPDATE table SET last_login=NOW() WHERE id=table.id");
It doesnt seem to work. I am trying to use the id of the first query to update the second. is this possible
That will update all your records with session = ‘1’. Assuming of course that the subquery returns more than one result set, which from what I can see, it will.
This also allows you to drop the
multi_query()method, as it’s just a single query.In response to the comment:
According to http://lists.mysql.com/mysql/219882 this doesn’t appear to be possible with MySQL. Although I suppose you could go for something like:
Which is ugly, performing the same query twice, but should do what you want.