View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 11:28 AM
ZeldorBlat
 
Posts: n/a
Default Re: Is it possible to combine a SELECT and UPDATE in a single query

On Sep 27, 5:55 pm, qwerty...@googlemail.com wrote:
> Is it possible to combine both of these queries into a single one so a
> connection is reserved immediately when found so a competing script
> doesn't take up the connection in between
>
> SELECT Server_ID, Server_Address, Server_Port WHERE
> Servers.Server_Connections_In_Use < Servers.Server_Max_Connections
> LIMIT 1"
>
> UPDATE Servers SET Server_Connections_In_Use =
> Server_Connections_In_Use+1 WHERE Server_ID = '$Server_ID' LIMIT 1


Use transactions:

<http://dev.mysql.com/doc/refman/5.0/en/commit.html>

Reply With Quote