56,940
社区成员




(select id from t_qqwx_1986 where tag=0 limit 0,1) b
这个地方有点不明白什么意思,能说明下最好了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: 0
mysql> select * from t_qqwx_1986;
+----+------+
| id | tag |
+----+------+
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
| 4 | 1 |
+----+------+
4 rows in set (0.00 sec)
mysql>
update table1 a, (select id table1 where tag=0 limit 0,1) b
set a.tag=1
where a.id=b.id