2010-06-01 42 views

回答

3

仔细检查语法(我写它的SQL Server)。

SELECT u.id, u.name 
FROM Unit as u 
LEFT JOIN UnitCategoryIndex as uci 
ON u.id = uci.UnitId 
where uci.id is null 
+0

工程很好,谢谢安倍 – 2010-06-01 15:31:55

1
SELECT id FROM Unit WHERE NOT EXISTS (SELECT 1 FROM UnitCategoryIndex WHERE Unit.id = UnitCategoryIndex.unitid) 
1
select * 
    from unit U 
where not exists (select * 
         from unitcategoryindex X 
        where X.unitid = U.id 
       )