Queries to get data from sakila database using Structured Query Languange (SQL):
Assuming that you have created a Database already, with tables in it, containing at least 50 records and these fields:
ACTOR_LASTNAME, ACTOR_FIRSTNAME, FILM_TITLE
Take note that the database and table name is both "sakila".
1. We can fetch, display or get data using SELECT command or query. Let's type the command like this:
SELECT ACTOR_LASTNAME, ACTOR_FIRSTNAME, FILM_TITLE FROM sakila
The command above is called SELECT command that would allow you to display records inside your table. Normally SQL programmers would execute SELECT * command, but since we are just required to display three (3) columns only, then we could just select the column names for our data display. Your columns are: SELECT ACTOR_LASTNAME, ACTOR_FIRSTNAME and FILM_TITLE.
2. For the second command or query, we can execute this:
SELECT ACTOR_LASTNAME FROM sakila WHERE ACTOR_LASTNAME 'M%' ORDER BY ACTOR_LASTNAME .
The select where command is like a conditional statement (IF). Where is the statement used to display ACTOR_LASTNAME field starting with letter M. The ORDER BY command is the arrangement of the names in alphabetical order.