Querying tables in MySQL
To get data out of MySQL, we use a SELECT query. A basic SELECT query has the following format:
SELECT <items> FROM <table>
Here, <items> can be many different kinds of things. It can be a wildcard (*) character, which returns all columns from a table, a list of columns, or even something that's not in the table at all but should still be in resultset – for example, a constant such as production or number. The FROM <table> part is optional, but it is there in most cases.
The SQL language is a declarative language, which means that the focus is more on the results that are obtained rather than how they are obtained. This is why we describe in a SELECT statement what the returned data should look like (for example, what fields it should have). We don't instruct the database to open the data file and navigate through the data structures. Based on the instructions we give for what the results should look like,...