更新查询问题 [英] Update Query Issues

查看:51
本文介绍了更新查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的更新查询.

    UPDATE sugarcrm.qb_salesorders_leads_c, sugarcrm.qb_salesorders
    SET sugarcrm.qb_salesorders_leads_c.qb_salesorders_leadsleads_ida = sugarcrm.qb_salesorders.memo, sugarcrm.qb_salesorders_leads_c.qb_salesorders_leadsqb_salesorders_idb = sugarcrm.qb_salesorders.id
    WHERE sugarcrm.qb_salesorders.id = sugarcrm.qb_salesorders_leads_c.qb_salesorders_leadsqb_salesorders_idb

当我运行它时,它给了我受影响的行 0.

When I run this it gives me Affected rows 0.

这是我的 select 语句,使用与 WHERE 语句中相同的信息.

Here is my select statement using the same info that is in the WHERE statement.

    SELECT * from qb_salesorders_leads_c, sugarcrm.qb_salesorders 
    WHERE sugarcrm.qb_salesorders_leads_c.qb_salesorders_leadsqb_salesorders_idb = sugarcrm.qb_salesorders.id

这将返回 354 行,这是我期望在更新查询中更新的内容.我错过了什么.请帮忙!

This returns 354 Rows which is what I am expecting to update on the update query. What am I missing. Please help!

推荐答案

将隐式连接转换为显式连接:

Convert the implicit join to an explicit one:

UPDATE sugarcrm.qb_salesorders_leads_c leads 
    INNER JOIN sugarcrm.qb_salesorders orders
    ON orders.id = leads.qb_salesorders_leadsqb_salesorders_idb
SET leads.qb_salesorders_leadsleads_ida = orders.memo, 
    leads.qb_salesorders_leadsqb_salesorders_idb = orders.id

如您所见,我还使用别名使 SQL 简洁易读.

As you can see, I also used aliases to make the SQL compact and legible.

这篇关于更新查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆