2021年1月27日星期三

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

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.

https://stackoverflow.com/questions/65921170/how-to-only-get-the-rows-in-which-every-value-is-found-from-another-table January 27, 2021 at 10:28PM

没有评论:

发表评论