I have 3 tables in total. I am trying to select the price of the cost food has to be the highest and the category name have to fall under organic.
I have came up with the following SQL QUERY but i have received an invalid relation error.
Could someone point me out what the problem might be ?
Thanks
SELECT PRICE, LABEL
FROM FOOD
WHERE FOOD.FOOD_ID = (
SELECT FOOD_ID
FROM FOOD_CATEGORY
WHERE FOOD_CATEGORY.FOOD_ID = (
SELECT FOOD_ID
FROM CATEGORY
WHERE NAME = 'ORGANIC'
)
);
FOOD
- FOOD_ID
- LABEL
- PRICE
FOOD_CATEGORY
- FOOD_ID
- CATEGORY_ID
CATEGORY
- CATEGORY_ID
- NAME
Relationship
FOOD.FOOD_ID = FOOD_CATEGORY.FOODID
FOOD_CATEGORY.CATEGORYID = CATEGORY.CATEGORYID
inrather than=. But, you should really learn to write this query using explicitjoinsyntax.