我正在尝试获取一个列的值,其中查询在使用不同的搜索字段搜索之前的表之后查找一个表上的同一列 - 但它出现空白。这是正确的方法吗?
示例数据:
cmsPropertyData
propertytypeid | dataNvarchar
-----------
1 | orange
2 | apple
3 | pear
cmsPropertyType
id | Alias
-------
1 | blue
2 | green
3 | red
cmsContent
nodeId
--------
1
2
3
cmsContentType
id | alias
----------------
1 | holiday
2 | flight
3 | carhire
SELECT pd.dataNvarchar
FROM [cmsPropertyData] pd
INNER JOIN [cmsPropertyType] pt
ON pt.id = pd.propertytypeid
INNER JOIN [cmsContent] c
ON c.nodeId = pd.contentNodeId
INNER JOIN [cmsContentType] ct
ON ct.nodeId = c.contentType
INNER JOIN [cmsPropertyType] z ON pd.id = z.id
WHERE ct.alias = 'holiday'
AND
pt.Alias = 'blue'
AND
pd.dataNvarchar = 'orange'
AND
z.Alias = 'green'
所以使用示例数据,我试图从cmsPropertyData中检索'apple'(pd.dataNvarchar)