Hello,
I am after an SQL command to find units with no categories. Here are the tables:
Unit
id name
UnitCategory
id name
UnitCategoryIndex
id categoryid unitid
Thanks!
Hello,
I am after an SQL command to find units with no categories. Here are the tables:
Unit
id name
UnitCategory
id name
UnitCategoryIndex
id categoryid unitid
Thanks!
SELECT id FROM Unit WHERE NOT EXISTS (SELECT 1 FROM UnitCategoryIndex WHERE Unit.id = UnitCategoryIndex.unitid)
select *
from unit U
where not exists ( select *
from unitcategoryindex X
where X.unitid = U.id
)
Double check the syntax (i wrote it for 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