Mysql 无法绑定多部分标识符以插入查询

Mysql 无法绑定多部分标识符以插入查询,mysql,sql,Mysql,Sql,我有一张表,上面有患者id、手术id(表1)。我需要插入从(表2)到(表3)的所有体重、身高详细信息,表2.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

我有一张表,上面有患者id、手术id(表1)。我需要插入从(表2)到(表3)的所有体重、身高详细信息,表2.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)

您可以在下面尝试-使用
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 

您可以在下面尝试-使用
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 

在主
SELECT
查询中无法访问
b
的表别名的可能重复项。由于
WHERE IN()
作为子查询执行,因此需要使用
JOIN
来建立别名。在主
SELECT
查询中无法访问
b
的表别名的可能重复项。由于
WHERE IN()
作为子查询执行,因此需要使用
JOIN
来建立别名。