sql >> Database teknologi >  >> RDS >> Mysql

MySQL Relationel Division

Prøv dette:

SELECT DISTINCT fb1.name, fb1.surname FROM favoriteBeer fb1
JOIN stock s ON fb1.beerName = s.beerName
GROUP BY fb1.name, fb1.surname, s.restaurant
HAVING COUNT(*) = (
  SELECT COUNT(*) FROM favoriteBeer fb2
  WHERE fb1.name = fb2.name AND fb1.surname = fb2.surname
)
 

Output:

| NAME | SURNAME | |-------------|-----------| | Bucher | Rolf | | Mastroyanni | Pepe | | Meier | Hans | | Meier | Hanspeter | | Meier | Hansruedi | | Müller | Heinrich | | Peters | Peter | | Zarro | Darween |

Violin her .




  1. Bedste praksis for effektiv lagring af md5-hash i mysql

  2. upload en fil til en MySql DB med PHP

  3. Knex.js - Hvordan opretter man et unikt indeks med 'where'-klausul?

  4. Entity Framework Cascade Slet