gpt4 book ai didi

mysql - 无法为插入查询绑定(bind)多部分标识符

转载 作者:行者123 更新时间:2023-11-30 21:27:56 25 4
gpt4 key购买 nike

我有一张包含 Patient_id、surgery_dt(Table1) 的表格。我需要插入从 (Table2) 到 (Table3) 的所有体重、高度详细信息,其中 Table2.date 在 surgery_dt 6 个月之前和之后。

我与您分享我尝试过的代码。但它返回:“无法绑定(bind)多部分标识符“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

关于mysql - 无法为插入查询绑定(bind)多部分标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57967933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com