php - mysql select where in select as variable -
i have next select statement
select a.firstname name, m.date time business relationship left bring together memberships m on a.id = m.account_id a.is_active = 1 i trying check , see if user has active membership (there more one, 1 need proof) , if set variable true or id or something, if not false (or null or whatever)
here have far
select a.firstname name, p.date time m.id active_membership business relationship left bring together profile p on a.id = p.account_id a.id in (select distinct account_id memberships active = 1) , a.is_active = 1 so results trying name, time, active_membership foo, 10:00, null bar, 14:00, 223(id or anything)
i got working take in part...
you need left join.
select a.firstname name, p.date time, if(m.account_id null, "no", "yes") active_membership business relationship left bring together profile p on a.id = p.account_id left bring together (select distinct account_id memberships active = 1) m on a.id = m.account_id a.is_active = 1 php mysql sql
No comments:
Post a Comment