Joining tables

It is also possible to select data from 2 or more tables at once. This is particularly useful if the tables have a relation.
For example, we have a list of people in the contacts table. Each of these contacts works for a company, stored in the companies table. We could get a list of contacts and the name of their company using the following statement:
SELECT contacts.*, companies.name AS company
FROM contacts, companies
WHERE comapnies.id = con­tacts.company_id
This is the same as:
SELECT contacts.*, companies.name AS company
FROM contacts
INNER JOIN companies
ON companies.id = contacts.company_id
The AS keyword is used to assign a name to a column in the query result. Use this to provide more descriptive names for columns or to prevent 2 columns from having the same name.
The JOIN keyword is used to explicitly specify how to combine two tables to a set of results.