SQL 无法绑定多部分标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2531924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The multi-part identifier could not be bound
提问by jello
I have this very simple sql statement:
我有这个非常简单的 sql 语句:
SELECT max_dose
FROM psychotropes
WHERE (patient_meds.psychotrope = psychotrope_name) AND (patient_meds.patient_id = 12)
when I try to run it in Visual Studio 2008, it tells me "The multi-part 'patient_meds.psychotrope' identifier could not be bound"
当我尝试在 Visual Studio 2008 中运行它时,它告诉我“无法绑定多部分 'patient_meds.psychotrope' 标识符”
it's weird, because I did set a relationship between the two tables in the diagram viewer
这很奇怪,因为我确实在图表查看器中设置了两个表之间的关系
回答by codaddict
I guess you'll have to include patient_meds
in the table list as:
我想你必须包括patient_meds
在表格列表中:
FROM psychotropes, patient_meds
回答by Dustin Laine
You are not including the table in the query. Without knowing the schema this is just an assumption. Also a database diagram does nothing to assist in queries.
您没有在查询中包含该表。在不知道架构的情况下,这只是一个假设。此外,数据库图对查询没有任何帮助。
SELECT ax_dose
FROM psychotropes
INNER JOIN patient_meds ON psychotropes.psychotrope_name = patient_meds.psychotrope
WHERE (patient_meds.patient_id = 12)