无法绑定多部分标识符

时间:2022-08-16 09:18:33

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

这很奇怪,因为我确实在图表查看器中设置了两个表之间的关系

2 个解决方案

#1


16  

I guess you'll have to include patient_meds in the table list as:

我想你必须在表格列表中包含patient_meds:

FROM psychotropes, patient_meds

#2


9  

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)

#1


16  

I guess you'll have to include patient_meds in the table list as:

我想你必须在表格列表中包含patient_meds:

FROM psychotropes, patient_meds

#2


9  

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)