Chapter 4: Selecting, Aggregating, and Applying Functions
In this chapter, we cover different ways to get the information we need out of MySQL data. We will learn how to filter out the records and apply functions on the data – for example, to only return the first 15 characters of a field. We will then start to use GROUP BY
to group rows and calculate results built on the groups. This is often used to sum all the values in a group or count how many items they are in one.
This chapter covers the following topics:
- An introduction to querying data
- Querying tables in MySQL
- Exercise 4.01 – simple queries
- Filtering results
- Exercise 4.02 – filtering results
- Using functions on data
- Exercise 4.03 – using functions
- Aggregating data
- Exercise 4.04 – aggregating data
- Case statements
- Exercise 4.05 – writing case statements
- Activity 4.01 – collecting information for a travel article