Nesting a SELECT in an UPDATE in a SELECT" == "Selecting the updated record from an update with a nested select"
I've been searching for most of the morning without any luck on this topic. I'm not sure if it's even entirely possible with SQL, but I would like to be able to SELECT a row of work in my table, based on my row status codes. I would then like to immediately set the status code to '1' and select the row that was updated.
I have the statement where I would "reserve" the work row:
UPDATE workTable SET pstat=1,pchby='user',pchtm=CURRENT_TIMESTAMP WHERE pstat=0 AND preqst=( SELECT preqst FROM workTable WHERE pstat=0 AND preqst=80650 OR preqst=80658 OR preqst=81284 LIMIT 1 );
I would like to somehow return the preqst of the row that I set the status code = '1'. Any help would be appreciated. I would like to stick as close to standard, cross-platform SQL as possible, if possible. Would "SELECT FOR UPDATE" do me any good? What about a temporary variable?
Thanks.
I've been searching for most of the morning without any luck on this topic. I'm not sure if it's even entirely possible with SQL, but I would like to be able to SELECT a row of work in my table, based on my row status codes. I would then like to immediately set the status code to '1' and select the row that was updated.
I have the statement where I would "reserve" the work row:
UPDATE workTable SET pstat=1,pchby='user',pchtm=CURRENT_TIMESTAMP WHERE pstat=0 AND preqst=( SELECT preqst FROM workTable WHERE pstat=0 AND preqst=80650 OR preqst=80658 OR preqst=81284 LIMIT 1 );
I would like to somehow return the preqst of the row that I set the status code = '1'. Any help would be appreciated. I would like to stick as close to standard, cross-platform SQL as possible, if possible. Would "SELECT FOR UPDATE" do me any good? What about a temporary variable?
Thanks.