MySQL Forums
Forum List  »  Newbie

Re: Select and update at the same time (with selected value)?
Posted by: Barry Galbraith
Date: June 17, 2010 09:33PM

Maybe this is what you want
mysql> show create table pool_process \G
*************************** 1. row ***************************
       Table: pool_process
Create Table: CREATE TABLE `pool_process` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` varchar(10) DEFAULT NULL,
  `any` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> select * from pool_process;
+----+--------+------+
| id | status | any  |
+----+--------+------+
|  1 |        |    1 |
|  2 |        |    1 |
+----+--------+------+
2 rows in set (0.00 sec)

mysql> update pool_process set status = 'RUNNING' where any = 1 and status = ''
order by id limit 1;
Query OK, 1 row affected (0.36 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from pool_process;
+----+---------+------+
| id | status  | any  |
+----+---------+------+
|  1 | RUNNING |    1 |
|  2 |         |    1 |
+----+---------+------+
2 rows in set (0.00 sec)

If not, then show us your table structure, and some data.

Good luck,
Barry.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.