Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Queries

Tags:

mysql

Having a little trouble with this question: Using the two tables below, create a subquery or join statement that shows the player, Team, and No in the Player_PROFILE table for all players coached by Fisher.

enter image description here

I came up with the following SQL code but I'm not sure how to finish it or if its even right:

SELECT PLAYER_PROFILE.Player, PLAYER_PROFILE.Team,
PLAYER_PROFILE.No
FROM PLAYER_PROFILE
INNER JOIN PLAYER_DETAIL
ON......
like image 946
web-dev Avatar asked Aug 16 '26 09:08

web-dev


2 Answers

Isnt it this - or am I missing something in your question

SELECT PLAYER_PROFILE.Player, PLAYER_PROFILE.Team, PLAYER_PROFILE.No
FROM PLAYER_PROFILE
INNER JOIN PLAYER_DETAIL ON PLAYER_PROFILE.Player=PLAYER_DETAIL.Player
WHERE PLAYER_DETAIL.Coach = 'Fisher';
like image 67
PaulF Avatar answered Aug 17 '26 22:08

PaulF


SELECT PLAYER_PROFILE.Player, PLAYER_PROFILE.Team,
PLAYER_PROFILE.No
FROM PLAYER_PROFILE
INNER JOIN PLAYER_DETAIL
ON PLAYER_PROFILE.Player = PLAYER_DETAIL.Player
WHERE PLAYER_DETAIL.Coach = "Fisher"

You do the inner join (http://www.w3schools.com/sql/sql_join_inner.asp) on the player name because you need some piece of data that is unique for each player ... normally this would be some sort of ID (number/guid) but in the case of your data, it is the player name.

like image 27
3-14159265358979323846264 Avatar answered Aug 17 '26 21:08

3-14159265358979323846264



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!