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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -