SQL語法學習心得
第四篇(JOIN)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
線上SQL測試網站
3 table
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
JOIN
id and matchid is the join index of two table
- show the player, teamid, stadium and mdate for every German goal
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Show the team1, team2 and player for every goal scored by a player called Mario
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Show player, teamid, coach, gtime for all goals scored in the first 10 minutes
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Catious for same index in different table
If one col name appears in two table, we must specify
table.col to avoid error.
List the dates of the matches and the name of the team in which 'Fernando Santos' was the team1 coach.
Since id
is in both game and eteam table, we must specify eteam.id
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Difficult Question
- show the name of all players who scored a goal against Germany
use DISTINCT to filter out duplicate query
Someone might score against Germany in different games
Also teamid cannot be Germany
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Show teamname and the total number of goals scored.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
GROUP BY Application (Tricky)
- every match involving 'POL', show the matchid, date and the number of goals scored.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Two example above: GROUP BY with 2 indexes
CASE - WHEN - THEN - END
If it was a team 1 goal then a 1 appears in score 1, otherwise there is a 0. You could SUM this column to get a count of the goals scored by team1. Sort your result by mdate, matchid, team1 and team2. Example output:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
NEW Command : LEFT JOIN will be introduce later
More tutorial / note
- my coding-blog
- my movie-blog