I am creating my first left join and I am having syntax errors. I been up and down this list and I cannot figure what is the issue. Here is the setup
I have three tables Mass_List
, Parent
and Parent_Place
. They all have the same ID but I need to get the Date_Close
from Mass_List
and the ID
and Username
from Parent
, making sure that the user is a paying member, which is know by the column MBSHIP
in Parent_Place
.
I do the queries separate and they work but when I do the queries together it tells me my syntax is correct but gives me the following error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I searched online but nothing close to my case. Any idea what's wrong with my syntax? Here is the query
SELECT P.USERNAME, M.DATE_CLOSE, P.ID
FROM MASS_LIST M, PARENT P
WHERE P.ID =
(SELECT M.ID
FROM MASS_LIST M
INNER JOIN PARENT_PLACE PP ON PP.ID = M.ID
WHERE PP.CLASS_USR = 'PAID'
AND M.DATE_CLOSE > getdate()
AND PP.MBSHIP > 0)
AND M.DATE_CLOSE > GETDATE() ORDER BY M.DATE_CLOSE;