要求更改查询到的第一个满足tag=0条件的改为tag=1
就是这个意思,下面是错的
update table1 set tag=1 where id=(select id from table1 where tag=0 limit 0,1);
就是这个意思,下面是错的
update table1 set tag=1 where id=(select id from table1 where tag=0 limit 0,1);
set a.tag=1
where a.id=b.id
update t_qqwx_1986 a, (select id from t_qqwx_1986 where tag=0 limit 0,1) b
set a.tag=1
where a.id=b.id测试如下.mysql> select * from t_qqwx_1986;
+----+------+
| id | tag |
+----+------+
| 1 | 1 |
| 2 | 0 |
| 3 | 0 |
| 4 | 1 |
+----+------+
4 rows in set (0.00 sec)mysql> update t_qqwx_1986 a, (select id from t_qqwx_1986 where tag=0 limit 0,1) b
-> set a.tag=1
-> where a.id=b.id;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql> select * from t_qqwx_1986;
+----+------+
| id | tag |
+----+------+
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 1 |
+----+------+
4 rows in set (0.00 sec)mysql>