i have the following select statement
SELECT
a.firstname name,
m.date time
FROM
account a
LEFT JOIN memberships m ON a.id = m.account_id
WHERE
a.is_active = 1
i am trying check and see if the user has an active membership (there could be more than one, but one is all i need as proof) and if so then set the variable true or the id or something, if not then false (or null or whatever)
here is what i have so far
SELECT
a.firstname name,
p.date time
m.id active_membership
FROM
account a
LEFT JOIN profile p ON a.id = p.account_id
WHERE
a.id IN (SELECT DISTINCT account_id FROM memberships WHERE active = 1)
AND
a.is_active = 1
so the results i am trying to get would be name, time, active_membership foo, 10:00, null bar, 14:00, 223(id or anything)
i got everything working accept for the where in part...
EXISTShere.RIGHT JOINto force only records that have an associated account to load.