I have table ItemPropertyValue with unique ID and PropertyID
ID IDProperty Value ItemID
1 1 1 5
2 2 2 6
3 3 2 10
4 4 2 15
And another table called PropertyCategory
IDProperty Value Name
1 1 First Option
1 2 Second Option
2 1 Another option
What I want – it’s to select PropertyID from first table ItemPropertyValue where ItemID = 10 and then join with second table PropertyCategory
So I have smth like this:
IDProperty Value Name
1 1 First Option
1 2 Second Option
2 1 Another option
I tried this but there is an error. No such column as PropertyID
SELECT * FROM PropertyCategory JOIN
(SELECT ItemPropertyValue.IDProperty AS PropertyID
WHERE ItemPropertyValue.IDItem = '10')
ON PropertyCategory.IDProperty = PropertyID
How can I do it?
MS SQLServer if any
Use table alias: