【问题标题】:Multi part identifier could not be bound for inserting query无法为插入查询绑定多部分标识符
【发布时间】:2019-09-17 05:39:29
【问题描述】:

我有一张带有 Patient_id、surgical_dt(Table1) 的表格。我需要插入从 (Table2) 到 (Table3) 的所有体重、身高详细信息,其中 Table2.date 在 6 个月的手术时间前后落下。

我与您分享我尝试过的代码。但它返回: “无法绑定多部分标识符“b.Sur_dt”。”

请提出一些解决问题的想法。 提前致谢!

    select a.patient_id,a.Record_Date,a.Height,a.Weight,a.Waist,a.hip into Table3 from Table2 a
where a.Record_Date between b.Sur_dt-180 and b.Sur_dt+180 and a.Patient_id in (select b.Patient_id from Table1 b where a.patient_id = b.patient_id)

【问题讨论】:

标签: mysql sql


【解决方案1】:

您可以在下面尝试 - 使用 JOIN

select a.patient_id,a.Record_Date,a.Height,a.Weight,a.Waist,a.hip into Table3 
from Table2 a inner join Table1 b on a.patient_id = b.patient_id
where a.Record_Date between b.Sur_dt-180 and b.Sur_dt+180 

【讨论】:

    猜你喜欢
    • 2012-08-17
    • 2013-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    相关资源
    最近更新 更多