sql - MySQL query all outcome from a table where the field's values all exist in another table -


for example, merchant(m_id), bill(b_id, m_id, payer_name) how can payer buy every merchant? used group by , compare count, bill can occur times same payer , same merchant. think need function likewhere m_id in (select m_id merchant).

there couple ways of doing this. here's 1 using subquery:

select payer_name bill  group payer_name having count(distinct m_id) = (select count(*) merchant) 

Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -