我有一个表测试,结构如下所示
mysql> select * from test;
+----+------------+------------+---------+-----+------+------+
| id | is_deleted | sort_order | version | cid | pid | qid |
+----+------------+------------+---------+-----+------+------+
| 14 | | 6 | 0 | 1 | 2 | 7 |
| 18 | | 1 | 2 | 1 | 4 | 12 |
| 26 | | 9 | 0 | 1 | 1 | 1 |
| 40 | | 1 | 0 | 1 | 5 | 18 |
| 49 | | 2 | 0 | 1 | 5 | 35 |
| 50 | | 3 | 0 | 1 | 5 | 39 |
| 51 | | 4 | 0 | 1 | 5 | 40 |
| 61 | | 10 | 0 | 1 | 1 | 2 |
| 62 | | 11 | 0 | 1 | 1 | 3 |
| 63 | | 12 | 0 | 1 | 1 | 4 |
| 64 | | 13 | 0 | 1 | 1 | 42 |
| 65 | | 14 | 0 | 1 | 1 | 43 |
| 66 | | 2 | 0 | 1 | 4 | 26 |
| 67 | | 3 | 0 | 1 | 4 | 38 |
| 71 | | 7 | 0 | 1 | 2 | 2 |
| 72 | | 8 | 0 | 1 | 2 | 8 |
| 73 | | 9 | 0 | 1 | 2 | 50 |
| 74 | | 10 | 0 | 1 | 2 | 51 |
| 76 | | 3 | 0 | 1 | 3 | 9 |
| 78 | | 4 | 0 | 1 | 3 | 53 |
| 79 | | 1 | 0 | 1 | 6 | 54 |
| 80 | | 1 | 0 | 1 | 11 | 59 |
| 81 | | 1 | 0 | 1 | 12 | 70 |
+----+------------+------------+---------+-----+------+------+
我想将版本设置为cid = 1,pid不等于6,11且qid不等于28,59,54的所有行中的1行
任何人都可以告诉我该怎么做?
答案 0 :(得分:4)
UPDATE test
SET `version` = 1
WHERE cid =1
AND pid NOT in(6,11)
AND qid NOT IN (28,59,54);