Filter data-WHERE

Foreword: This chapter will explain how to use the keyword WHER to specify search criteria and achieve the effect of filtering data

Database tables generally contain a large amount of data, and it is rarely necessary to retrieve all rows. Generally, only the required data is retrieved, so that filter conditions need to be used.

 

WHERE filter data

  •  Check a single value, in the SELECT statement, the data will be filtered according to the search conditions specified in the WHERE clause, the WHERE clause after the FROM clause
  • When the filter condition is a string, you need to quote single quotes '', when the filter condition is a value, you do not need to quote single quotes
SELECT name FROM user WHERE age=28
SELECT name FROM user WHERE age < 28
  • Mismatch check
SELECT name FROM user WHERE age != 28

SELECT name FROM user WHERE age <> 28
  • Range value check (BETWEEN AND)
SELECT name FROM user WHERE age BETWEEN 10 AND 20
  • NULL check (IS NULL)
SELECT * FROM user WHERE name IS NULL

 

Published 138 original articles · praised 34 · 150,000 views

Guess you like

Origin blog.csdn.net/bbj12345678/article/details/105466537