View Single Post

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


> > How about:
> >
> > UPDATE Servers SET Server_Connections_In_Use =
> > Server_Connections_In_Use+1 WHERE Server_ID =
> > (SELECT Server_ID WHERE
> > Servers.Server_Connections_In_Use < Servers.Server_Max_Connections
> > LIMIT 1)

>
> Thanks but:
>
> "There is one caveat: It is not currently possible to modify a table
> and select from the same table in a subquery."
> http://dev.mysql.com/tech-resources/...ubqueries.html


Oh, right. Sorry for that, I don't usually do MySQL SQL statements.

Silly restriction, really.


--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com


Reply With Quote