SQL: Retrieving filtered data from a table

This entry is part 7 of 20 in the series SQL Tutorial

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

SQL: CRUD

This entry is part 5 of 20 in the series SQL Tutorial

The acronym CRUD (create, read, update, delete) refers to the major functions that are implemented in relational database.  Once you have mastered these 4 functions, you will be quite proficient in manipulating the database, just like manipulating the DOM in web programming.

FunctionSQL
createinsert
readselect
updateupdate
deletedelete

In the earlier examples, we have already used insert into and select statements.

In the upcoming posts, we will delve further into the select statements.