1. SELECT on tables
As we can read single values we try to read data from a table.
We extend the SELECT query by the FROM ... keyword.
The ... part is the table we want to read. If we have
select a table this way we can use the column names in the
SELECT part. So the syntax is SELECT columns FROM table.
As an example we reads the columns id, author
and title from our news table.
SELECT
author,
id,
title
FROM
news;
We get the following result set.
| author | id | title |
|---|---|---|
| 1 | ||
| Me | 2 | My first news |
We see we got a result set with 3 columns and 2 rows. This is okay as the table
got 2 rows and in the SELECT part we selected 3 columns. We also see the first
row got empty values but thats also okay as the row itself just got only empty values.
The order of the columns can be changed (we read id after author), but
it doesn't matter as we read them in php by their name rather by their position.