- Building a Web Application with PHP and MariaDB:A Reference Guide
- Sai Srinivas Sriparasa
- 290字
- 2021-07-16 11:36:56
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:

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

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

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

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

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.
- UML和模式應(yīng)用(原書第3版)
- AIRAndroid應(yīng)用開發(fā)實(shí)戰(zhàn)
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- Learning Apache Kafka(Second Edition)
- Java EE 7 Development with NetBeans 8
- Mastering Predictive Analytics with Python
- 運(yùn)用后端技術(shù)處理業(yè)務(wù)邏輯(藍(lán)橋杯軟件大賽培訓(xùn)教材-Java方向)
- jQuery Mobile移動(dòng)應(yīng)用開發(fā)實(shí)戰(zhàn)(第3版)
- 持續(xù)輕量級(jí)Java EE開發(fā):編寫可測(cè)試的代碼
- SSM開發(fā)實(shí)戰(zhàn)教程(Spring+Spring MVC+MyBatis)
- Drupal 8 Development:Beginner's Guide(Second Edition)
- 計(jì)算語言學(xué)導(dǎo)論
- C語言程序設(shè)計(jì)
- 系統(tǒng)分析師UML用例實(shí)戰(zhàn)
- Python程序設(shè)計(jì)案例教程