Can someone please tell me what is the issue with this code.
Basically what I am trying to do is to identify the renter based on their IDs rather than names (in case there are more renters with the same name). Thank you
SELECT DISTINCT P.PROPERTYId, P.PROPERTYName, T.TYPEName
FROM RENTAL R, PROPERTY P, TYPE T
Group by P.PROPERTYId, P.PROPERTYName, T.TYPEName
HAVING RENTERId = (SELECT RENTERId FROM RENTER
WHERE RENTERFirstName = 'AL'
AND RENTERLastName = 'SMITH')
AND R.PROPERTYId = P.PROPERTYId
AND P.TYPEId = T.TYPEId
AND T.TYPEName = 'VILLA';
Try this instead.
Note how the tables are linked using the
joinsyntax, and thewhereclause is reserved for filtering.