mysql notes(3)

Use where for conditional query:

SELECT prod_price ,prod_name 
FROM products p 
WHERE prod_price = 2.5; 
Insert picture description here
SELECT prod_price ,prod_name 
FROM products p 
WHERE prod_price = 2.5
ORDER BY prod_name DESC ; 
--  order by 只能在最后
Insert picture description here

<> and != have the same effect. The between and and keywords are used together to take the number between two values.

SELECT prod_name ,prod_price 
FROM products p
WHERE prod_price  
BETWEEN 2.5 AND 10 
ORDER BY prod_price ;
Insert picture description here

Use IS NULL to determine whether the column can store NULL;

SELECT cust_id ,cust_name ,cust_email 
FROM customers c 
WHERE cust_email IS NULL ;
Insert picture description here

When filtering data, it will not actively return NULL rows that meet the conditions, as shown in the following example.

SELECT cust_id ,cust_email 
FROM customers c ;
Insert picture description here
SELECT cust_id ,cust_email 
FROM customers c 
WHERE cust_email != '[email protected]' 
AND cust_email != '[email protected]';
Insert picture description here