Chapter 5: Selecting Data Part 1

 

In this chapter, we’ll learn to select data from our database. This is a relatively large topic, so we’ll be splitting it into three chapters.

 

The data used for selection are from the two tables (employees and mentorships) that we created in the previous chapters. These tables can be found in Appendix A for easy reference.

 

In the first chapter, we’ll learn to select data from a single table.

 

Basic Select Syntax

 

To select data from a single table, we use the syntax

 

SELECT column_names_or_other_information

[AS alias]

[ORDER BY column(s)] [DESC]

FROM table_name

[WHERE condition];

 

Let’s look at some examples.

 

Selecting Everything

 

If we want to select all the columns and rows from a table, we ...

Get Learn SQL using MySQL in One Day and Learn It Well 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.