SQL Flashcards

1
Q

SELECT

A
  • Determines what fields you want to select, and therefore show in the final output.
  • You can either select individual field (separated by a comma) or all fields using an Asterisk (*).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

FROM

A
  • Indicates which table you are querying
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

WHERE

A
  • The condition you are setting.
  • You don’t need to have this part if you don’t want to set a condition.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: Write the SQL to locate all the records where the wins is 14 (in the premier league table)

A
  • The question does not specify which fields to pull out, therefore we will pull them all out.
  • SELECT *
  • Secondly, we now need to indicate which table we are using.
  • It is called Premier.
  • SELECT * FROM Premier
  • The question is asking us to locate the records where the wins is 14.
  • That is our condition, that the team must have 14 wins.
  • We need to know what the name of the field is where the wins are stored.
  • In this table it is called W. Here is our final SQL query with the condition now added:
  • SELECT * FROM Premier WHERE W = 14
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: Write the SQL to locate all the team name and points where the losses is less than 11.

A
  • In this question we have got specific fields to extract (team name and points).
  • In this table the team name is the field called club, and the points is called Pts. Here is our SQL query so far:
  • SELECT Club, Pts
  • Secondly, we now need to indicate which table we are using.
  • It is called Premier.
  • Here is our SQL query now with the FROM statement attached:
  • SELECT Club, Pts FROM Premier
  • The question is asking us to locate the records where the number of losses is less than 11.
  • That is our condition, that the team must have less than 11 losses.
  • We need to know what the name of the field is where the losses are stored. In this table it is called L. - Here is our final SQL query with the condition now added:
  • SELECT Club, Pts FROM Premier WHERE L < 11
How well did you know this?
1
Not at all
2
3
4
5
Perfectly