1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to only get the rows in which every value is found from another table?

Discussão em 'Outras Linguagens' iniciado por Stack, Janeiro 27, 2021.

  1. Stack

    Stack Membro Participativo

    I have the following table schema:

    Person:


    Name | Year | Sports
    Hans | 23 | Football
    Hans | 23 | Baseball
    Hans | 23 | Badminton
    Albert | 25 | Baseball
    Albert | 25 | Badminton

    Sports:


    Name | Tempo | Amount
    Football | Fast | 5
    Baseball | Slow | 3
    Badminton | Fast | 4

    Speed:


    Name | Star
    Fast | Good
    Slow | Bad


    The question I am trying to solve is: Which Sports are used by every person and also has the star value good?

    The result I want:


    Albert | 25 | Badminton


    My question would be: How can I realize this with a select statement? My current solution is:

    SELECT * FROM speed JOIN
    (SELECT * FROM person JOIN sports USING (name)) USING (name) WHERE STAR = 'good'


    I don't know how to filter this more.

    Continue reading...

Compartilhe esta Página