SQL: Retrieving filtered data from a table

The most common task is to retrieve filtered data from a table.

SQL Select Syntax
select column_name,column_name
from table_name where column_name = ;

and

select * from table_name where column_name = ;
Example Table
IDartistealbumyear
1Rod StewartMaggie May1973
2New OrderSubstance1987
3NirvanaSmell Like Teen Spirit1992

If we have a table like above, we could ask ourselves questions like:

  1. What is the name of the album released by Rod Stewart?
  2. When did Rod Stewart release the album Maggie May?
  3. Who released the album Substance in the year 1987?

What is the name of the album released by Rod Stewart?

select album from artiste where artiste='Rod Stewart'

Answer:  Maggie May


When did Rod Stewart release the album Maggie May?

select year from artiste where album='Maggie May'

Answer:  1973


Who released the album Substance in the year 1987?

select album from artiste where year=1987

Answer:  Substance

Series Navigation<< SQL: Select count
SQL: Select distinct >>