Course Content
SQL Tutorial for Beginners
SQL Tutorial for Beginners
SQL Where
You’ll need to filter your selected data very often, so you need to use WHERE keyword. After WHERE you put some condition or combination of them. Usually it is some column's values limitations.
For example, you want to select records where singer
is AC/DC:
SELECT * FROM songs WHERE singer = 'AC/DC'
Another example of the query using the WHERE statement. It retrieves all records with a price
column value greater than 100. The syntax is pretty easy to understand: WHERE price > 100.
SELECT * FROM songs WHERE price > 100
Here you can see the main syntax.
- Use = to find fields which values are equal to some naming.
- Use != or <> to find non-equal fields.
- Use >, <, >=, <= for comparing.
- Use single quotes
'Quotes'
for string values. - Use () brackets for prioritization.
/* all records where year column is greater or equal than 1970*/ SELECT * FROM songs WHERE year >= 1970
For string values, you have to write them inside single quotes. Like 'ABBA', 'Toxic' etc. Check carefully string values in the condition statements: no extra spaces, correct capitalization (for example,
Britney Spears
is correct, notBRITNEY SPEARS
orbritney spears
). Otherwise, you'll receive theInternal Server Error
.
Task
Select all records with Britney Spears as a singer. Change your query to select only Britney Spears songs' titles (not full records, only column title
).
Thanks for your feedback!
SQL Where
You’ll need to filter your selected data very often, so you need to use WHERE keyword. After WHERE you put some condition or combination of them. Usually it is some column's values limitations.
For example, you want to select records where singer
is AC/DC:
SELECT * FROM songs WHERE singer = 'AC/DC'
Another example of the query using the WHERE statement. It retrieves all records with a price
column value greater than 100. The syntax is pretty easy to understand: WHERE price > 100.
SELECT * FROM songs WHERE price > 100
Here you can see the main syntax.
- Use = to find fields which values are equal to some naming.
- Use != or <> to find non-equal fields.
- Use >, <, >=, <= for comparing.
- Use single quotes
'Quotes'
for string values. - Use () brackets for prioritization.
/* all records where year column is greater or equal than 1970*/ SELECT * FROM songs WHERE year >= 1970
For string values, you have to write them inside single quotes. Like 'ABBA', 'Toxic' etc. Check carefully string values in the condition statements: no extra spaces, correct capitalization (for example,
Britney Spears
is correct, notBRITNEY SPEARS
orbritney spears
). Otherwise, you'll receive theInternal Server Error
.
Task
Select all records with Britney Spears as a singer. Change your query to select only Britney Spears songs' titles (not full records, only column title
).
Thanks for your feedback!
SQL Where
You’ll need to filter your selected data very often, so you need to use WHERE keyword. After WHERE you put some condition or combination of them. Usually it is some column's values limitations.
For example, you want to select records where singer
is AC/DC:
SELECT * FROM songs WHERE singer = 'AC/DC'
Another example of the query using the WHERE statement. It retrieves all records with a price
column value greater than 100. The syntax is pretty easy to understand: WHERE price > 100.
SELECT * FROM songs WHERE price > 100
Here you can see the main syntax.
- Use = to find fields which values are equal to some naming.
- Use != or <> to find non-equal fields.
- Use >, <, >=, <= for comparing.
- Use single quotes
'Quotes'
for string values. - Use () brackets for prioritization.
/* all records where year column is greater or equal than 1970*/ SELECT * FROM songs WHERE year >= 1970
For string values, you have to write them inside single quotes. Like 'ABBA', 'Toxic' etc. Check carefully string values in the condition statements: no extra spaces, correct capitalization (for example,
Britney Spears
is correct, notBRITNEY SPEARS
orbritney spears
). Otherwise, you'll receive theInternal Server Error
.
Task
Select all records with Britney Spears as a singer. Change your query to select only Britney Spears songs' titles (not full records, only column title
).
Thanks for your feedback!
You’ll need to filter your selected data very often, so you need to use WHERE keyword. After WHERE you put some condition or combination of them. Usually it is some column's values limitations.
For example, you want to select records where singer
is AC/DC:
SELECT * FROM songs WHERE singer = 'AC/DC'
Another example of the query using the WHERE statement. It retrieves all records with a price
column value greater than 100. The syntax is pretty easy to understand: WHERE price > 100.
SELECT * FROM songs WHERE price > 100
Here you can see the main syntax.
- Use = to find fields which values are equal to some naming.
- Use != or <> to find non-equal fields.
- Use >, <, >=, <= for comparing.
- Use single quotes
'Quotes'
for string values. - Use () brackets for prioritization.
/* all records where year column is greater or equal than 1970*/ SELECT * FROM songs WHERE year >= 1970
For string values, you have to write them inside single quotes. Like 'ABBA', 'Toxic' etc. Check carefully string values in the condition statements: no extra spaces, correct capitalization (for example,
Britney Spears
is correct, notBRITNEY SPEARS
orbritney spears
). Otherwise, you'll receive theInternal Server Error
.
Task
Select all records with Britney Spears as a singer. Change your query to select only Britney Spears songs' titles (not full records, only column title
).