mysql - One many query where many has one record -
i have user table has many properties. user table having 1 many relation. try select users have 1 property in properties table
select *, count(p.account_id) c form accounts left join properties p on a.account_id = p.account_id group p.account_id having c = 1
but not seems work
select *, count(*) num accounts inner join properties p on a.account_id = p.account_id group p.account_id having num=1
Comments
Post a Comment