Retrieving Records
It does no good to put records in a database unless you retrieve them eventually and do something with them. That's the purpose of the SELECT statement: to help you get at your data. SELECT is probably the most commonly used statement in the SQL language, but it can also be the trickiest; the constraints you use to choose rows can be arbitrarily complex and can involve comparisons between columns in many tables.
The basic syntax of the SELECT statement looks like this:
SELECT selection_list | What columns to select |
FROM table_list | Where to select rows from |
WHERE primary_constraint | What conditions rows must satisfy |
GROUP BY grouping_columns | How to group results |
ORDER BYsorting_columns | How to sort results |
HAVINGsecondary_constraint | Secondary ... |
Get MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.