内连接嵌套在更新语句 SQL 中

Inner Join Nested Inside Update Statement SQL(内连接嵌套在更新语句 SQL 中)
本文介绍了内连接嵌套在更新语句 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);

MySql 的某些方面不喜欢 FROM 子句.

Something about MySql does not like the FROM clause.

推荐答案

对于更新,你在更新子句中指定join

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

这篇关于内连接嵌套在更新语句 SQL 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)