Mysql database is used
The SQL statement is as follows
1 UPDATE tb_cr_circulate_gtsc 2 set path_status='A06' 3 where 4 order_id='Ph800601211123155507' 5 and 6 receive_role='21075116-001' 7 and 8 receive_role_name='024722cd-b197-462f-bdc2-f0423d88e580&Z&11caea25-4996-4682-aa3c-ea698e5140cc&21075116-001&四川省川东农药化工有限公司' 9 and 10 ((select COUNT(path_status) FROM tb_cr_circulate_gtsc where order_id='Ph800601211123155507' and path_status='A04' and is_current_point='1' ) < (select COUNT(path_status) FROM tb_cr_circulate_gtsc where order_id='Ph800601211123155507' and is_current_point='1') )
According to the online query: you cannot select some values of the same table in the same SQL statement, and then update the table.
Solution: select multiple times through an intermediate table
1 ( 2 (SELECT statusSum from (select COUNT(path_status) as statusSum FROM tb_cr_circulate_gtsc where order_id='Ph800601211123155507' and path_status='A04' and is_current_point='1' ) ) 3 < 4 (SELECT statusSum from (select COUNT(path_status) as statusSum FROM tb_cr_circulate_gtsc where order_id='Ph800601211123155507' and is_current_point='1') ) 5 )
Similar Posts:
- sql Error: Every derived table must have its own alias [How to Solve]
- [Solved] MYSQL Error: You can’t specify target table for update in FROM clause
- You can’t specify target table for update….
- [Solved] MYSQL Error: “ Every derived table must have its own alias”
- [Solved] MYSQL ERROR 1093 – You can’t specify target table ‘readbook’ for update in FROM clause
- [Solved] MySQL Error Code: 1093. You can’t specify target table ‘car’ for update in …
- Hive SemanticException:Expression not in GROUP BY
- [Solved] no such column: id (code 1): , while compiling: DELETE FROM zhangdan WHERE id=?
- How to Use awk to Analyze Nginx Log
- How to Solve MYSQL Error: Every derived table must have its own alias