官术网_书友最值得收藏!

Filtering data

Until now, we have dealt with data retrieval where all the data in the students table is being retrieved, but seldom do we need all that data. We have used the LIMIT and OFFSET clauses that have allowed us to limit the amount of data were retrieved. Now let us use MariaDB's filtering mechanism to retrieve the data by supplying search criteria. To perform a search in a SQL statement, we will use the WHERE clause. The WHERE clause can be used with the SELECT statement, or it can be even used with the UPDATE and DELETE statements, which will be discussed in the next section:

Filtering data

In the preceding example, we are selecting the students' records whose last_name is Dane.

Filtering data

In the preceding example, we are selecting the students' records whose student_id is 1.

Filtering data

In the preceding example, we are selecting the students' records whose student_id is greater than 1.

Filtering data

In the preceding example, we are selecting the students' records whose student_id is less than 4.

Filtering data

In the preceding example, we are selecting the students' records whose student_id is between 1 and 4, the between clause is inclusive, so the records with student_id 1 and 4 are also retrieved. The following table lists the common operators that can be used for data filtering:

Data can also be filtered by utilizing multiple search criteria by using the AND and OR operators, by employing multiple column search criteria, by using wildcard filtering, by using the IN operator, and so on. As this chapter will only deal with basic filtering, we will not be covering these advanced filtering concepts. The basic filtering in this chapter can be used as a foundation to delve deeper into understanding the advanced concepts of filtering.

主站蜘蛛池模板: 安溪县| 宁化县| 新绛县| 封开县| 永康市| 镇赉县| 荃湾区| 杭锦旗| 江陵县| 海南省| 南投市| 嵊泗县| 邻水| 汾西县| 光泽县| 泸西县| 阜康市| 微山县| 芦山县| 锦屏县| 丹寨县| 永仁县| 吉隆县| 纳雍县| 岱山县| 南昌县| 泉州市| 固镇县| 咸宁市| 册亨县| 炉霍县| 盐源县| 松滋市| 莱州市| 庆元县| 探索| 聂荣县| 安丘市| 晋宁县| 阜平县| 景洪市|