For example, SQL reports an error:
table is specified twice, both as a target for 'Update' and as a separate source for data . The table is specified twice as both an update object and an independent data source.
Error reporting scenario: query the difference set of two tables and update the records. For example: perform an associated query on tables a and B to find out the records in table a that exist but not in table B, and then update a field in table a to mark.
Error reporting SQL:
UPDATE company AS f SET related = 0 WHERE uid IN ( select c.uid FROM company AS c LEFT JOIN member AS m ON m.uid=c.uid WHERE m.uid IS NULL )
Since a table cannot be both an update object and an independent data source, change one of them. Update is the main sentence, which cannot be removed, so you can only modify the table as the data source part. Take the results of the two table joint query as a temporary table and add a layer to the outer layer for query. In this way, the data source becomes a temporary table instead of the two tables for the previous associated query.
UPDATE company AS f SET related = 0 WHERE uid IN ( SELECT * FROM ( select c.uid FROM company AS c LEFT JOIN member AS m ON m.uid=c.uid WHERE m.uid IS NULL ) AS d )
- How to Delete using INNER JOIN with SQL Server?
- Using join buffer (Block Nested Loop)
- Oracle ORA-00936: missing expression [How to Solve]
- Using multiple tables_ Hash hint, are you right?
- Every derived table must have its own alias
- ERROR 1104 (42000): The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
- [Solved] must appear in the GROUP BY clause or be used in an aggregate function
- [Solved] Mybatis multi-table query error: Column ‘id’ in field list is ambiguous
- [Solved] Greenplum Use the Storage Error: function cannot execute on a QE slice because it accesses relation
- How to find real IP in CDN