我正在尝试获取一个SQL查询,以便为每个属性返回一个没有分配给它们的特定标记值的行,或者如果它们确实具有该标记值,那么它是空的。
下面的查询返回我所追求的内容,除非它返回多行,因为分配给它们的标记不同。我试过让一个小组去工作以返回单行,但无济于事。
SELECT t_package.Name AS SubPackageName
, t_object.Name as XTable
, t_attribute.Name as AttributeName
FROM (
(t_package AS t_package_1 INNER JOIN (t_package INNER JOIN t_object ON t_package.Package_ID = t_object.Package_ID) ON t_package_1.Package_ID = t_package.Parent_ID)
INNER JOIN t_attribute ON t_object.Object_ID = t_attribute.Object_ID)
LEFT JOIN t_attributetag ON t_attribute.ID = t_attributetag.ElementID
WHERE (((t_package_1.Name)='X')
AND ((t_object.Object_Type)='Class')
AND ((t_attribute.Type) NOT LIKE 'tns:%') )
AND (t_attributetag.Property <> 'dm_fieldref'
OR (t_attributetag.Property = 'dm_fieldref'
AND t_attributetag.VALUE is null))
ORDER BY SubPackageName, ICPTable, AttributeName;
答案 0 :(得分:1)
只需添加不同
即可SELECT distinct t_package.Name AS SubPackageName, t_object.Name as XTable...