Course Content
SQL Tutorial for Beginners
SQL Tutorial for Beginners
SQL And, Or, Not
To combine multiple conditions, use AND, OR, and NOT keywords, and also brackets (, ) to set the priority.
For example, you want to select all songs' titles, that were produced between 1970 and 1990 years:
SELECT title FROM songs WHERE year >= 1970 AND year <= 1990
Or you can select all records where singer is not Pink Floyd:
SELECT * FROM songs WHERE NOT singer = 'Pink Floyd'
You can combine conditions for different columns, but not forget about brackets to define the priority:
SELECT * FROM songs WHERE NOT (singer = 'Pink Floyd' AND price = 100)
Task
Find all songs title
s and price
s of 20th century, where the price
is less than 500, or where the singer
is AC/DC.
Thanks for your feedback!
SQL And, Or, Not
To combine multiple conditions, use AND, OR, and NOT keywords, and also brackets (, ) to set the priority.
For example, you want to select all songs' titles, that were produced between 1970 and 1990 years:
SELECT title FROM songs WHERE year >= 1970 AND year <= 1990
Or you can select all records where singer is not Pink Floyd:
SELECT * FROM songs WHERE NOT singer = 'Pink Floyd'
You can combine conditions for different columns, but not forget about brackets to define the priority:
SELECT * FROM songs WHERE NOT (singer = 'Pink Floyd' AND price = 100)
Task
Find all songs title
s and price
s of 20th century, where the price
is less than 500, or where the singer
is AC/DC.
Thanks for your feedback!
SQL And, Or, Not
To combine multiple conditions, use AND, OR, and NOT keywords, and also brackets (, ) to set the priority.
For example, you want to select all songs' titles, that were produced between 1970 and 1990 years:
SELECT title FROM songs WHERE year >= 1970 AND year <= 1990
Or you can select all records where singer is not Pink Floyd:
SELECT * FROM songs WHERE NOT singer = 'Pink Floyd'
You can combine conditions for different columns, but not forget about brackets to define the priority:
SELECT * FROM songs WHERE NOT (singer = 'Pink Floyd' AND price = 100)
Task
Find all songs title
s and price
s of 20th century, where the price
is less than 500, or where the singer
is AC/DC.
Thanks for your feedback!
To combine multiple conditions, use AND, OR, and NOT keywords, and also brackets (, ) to set the priority.
For example, you want to select all songs' titles, that were produced between 1970 and 1990 years:
SELECT title FROM songs WHERE year >= 1970 AND year <= 1990
Or you can select all records where singer is not Pink Floyd:
SELECT * FROM songs WHERE NOT singer = 'Pink Floyd'
You can combine conditions for different columns, but not forget about brackets to define the priority:
SELECT * FROM songs WHERE NOT (singer = 'Pink Floyd' AND price = 100)
Task
Find all songs title
s and price
s of 20th century, where the price
is less than 500, or where the singer
is AC/DC.