How to update multiple rows using single where clause

SpringLearner

I have a table test and the structure is as shown below

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 |
+----+------------+------------+---------+-----+------+------+

I want to set version to 1 of all the rows whose cid =1,pid not equal to 6,11 and qid not equal to 28,59,54

Can anybody please tell me how to do?

Sadikhasan
UPDATE test
SET `version` = 1
WHERE cid =1
  AND pid NOT in(6,11)
  AND qid NOT IN (28,59,54);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

UPDATE与UPDATE WHERE

来自分类Dev

Delete multiple rows by file name using Coldfusion

来自分类Dev

No rows returned using count in having clause

来自分类Dev

Using date from one table in a where clause with a column in a different table

来自分类Dev

How to use placeholders with "in (...)" clause?

来自分类Dev

在WHERE CLAUSE中使用子查询的结果

来自分类Dev

SQL-Server Update SET from SQL Where select is using a field from the table to update

来自分类Dev

IN Clause with WHERE clause not getting proper results in SQL Server

来自分类Dev

How to have multiple service.xml in a single plugin

来自分类Dev

Codeigniter, join of two tables with a WHERE clause

来自分类Dev

Mysql table joins using a where clause

来自分类Dev

How to add multiple if loop results to a single JOptionPane message dialog?

来自分类Dev

Build string for Linq WHERE clause depending on multiple checkbox choices

来自分类Dev

Insert into a specific row multiple values with Where clause?

来自分类Dev

IN clause with multiple columns

来自分类Dev

How to get all relationships of a node with cypher neo4j where clause, not only where matches

来自分类Dev

Multiple UPDATE in single transaction vs one UPDATE with big WHERE clause

来自分类Dev

build dynamic linq query in where clause

来自分类Dev

How to configure a single flask application to handle multiple domains?

来自分类Dev

How to select multiple rows by using grid.getSelectionModel().select(Indexes) in extjs 4.1

来自分类Dev

How do I do a simple "Update [table] where [anyfield] = [anyvalue]

来自分类Dev

Multiple functions to write into a single log file using Python

来自分类Dev

“ where-clause”中的未知列

来自分类Dev

Using WITH + DELETE clause in a single query in postgresql

来自分类Dev

Is it possible to use a conditional inside where clause in LinQ?

来自分类Dev

Chop a row into multiple rows using awk

来自分类Dev

Unknown Column in Where Clause : Mysql Update Query

来自分类Dev

匹配由SQL WHERE IN CLAUSE生成的结果

来自分类Dev

How to clone a single file using SourceTree?

Related 相关文章

  1. 1

    UPDATE与UPDATE WHERE

  2. 2

    Delete multiple rows by file name using Coldfusion

  3. 3

    No rows returned using count in having clause

  4. 4

    Using date from one table in a where clause with a column in a different table

  5. 5

    How to use placeholders with "in (...)" clause?

  6. 6

    在WHERE CLAUSE中使用子查询的结果

  7. 7

    SQL-Server Update SET from SQL Where select is using a field from the table to update

  8. 8

    IN Clause with WHERE clause not getting proper results in SQL Server

  9. 9

    How to have multiple service.xml in a single plugin

  10. 10

    Codeigniter, join of two tables with a WHERE clause

  11. 11

    Mysql table joins using a where clause

  12. 12

    How to add multiple if loop results to a single JOptionPane message dialog?

  13. 13

    Build string for Linq WHERE clause depending on multiple checkbox choices

  14. 14

    Insert into a specific row multiple values with Where clause?

  15. 15

    IN clause with multiple columns

  16. 16

    How to get all relationships of a node with cypher neo4j where clause, not only where matches

  17. 17

    Multiple UPDATE in single transaction vs one UPDATE with big WHERE clause

  18. 18

    build dynamic linq query in where clause

  19. 19

    How to configure a single flask application to handle multiple domains?

  20. 20

    How to select multiple rows by using grid.getSelectionModel().select(Indexes) in extjs 4.1

  21. 21

    How do I do a simple "Update [table] where [anyfield] = [anyvalue]

  22. 22

    Multiple functions to write into a single log file using Python

  23. 23

    “ where-clause”中的未知列

  24. 24

    Using WITH + DELETE clause in a single query in postgresql

  25. 25

    Is it possible to use a conditional inside where clause in LinQ?

  26. 26

    Chop a row into multiple rows using awk

  27. 27

    Unknown Column in Where Clause : Mysql Update Query

  28. 28

    匹配由SQL WHERE IN CLAUSE生成的结果

  29. 29

    How to clone a single file using SourceTree?

热门标签

归档