简体   繁体   中英

Inner Join Nested Inside Update Statement SQL

I am trying to write a query that performs an inner join within an update statement.

Here is the current query I am working with:

UPDATE 
    singulation1.`q096_cq33r08-ds01-n-testtable`
SET 
    visual = t2.visual,
    inspection_status = t2.inspection_status,
    inspector_name = t2.inspector_name
FROM 
    singulation1.`q096_cq33r08-ds01-n-testtable` t1
INNER JOIN 
    singulation1.`q014_bq31t05-dw30-x` t2
ON 
    (t1.print = t2.print AND t1.id3 = t2.id3);

Something about MySql does not like the FROM clause.

For updates, you specify the join in the update clause

UPDATE
    singulation1.`q096_cq33r08-ds01-n-testtable` AS t1
    INNER JOIN singulation1.`q014_bq31t05-dw30-x` AS t2
      ON t1.print = t2.print AND t1.id3 = t2.id3
SET
    t1.visual = t2.visual
    t1.inspection_status = t2.inspection_status,
    t1.inspector_name = t2.inspector_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM