2019.11.30 Mysql query knowledge

Is not equal to: <>

 

Empty condition is determined: null and blank (empty string)

 

Judging whether or not null: xxxx is not null / xxxx is null

Judgment null:

SELECT * FROM student WHERE address IS NULL ;

Analyzing empty string:

SELECT * FROM student WHERE address='';

And null empty string comprising:

SELECT * FROM student WHERE address IS NULL OR address='';  

 

Fuzzy query: like

SELECT * FROM score WHERE sname LIKE 'Great%'; (% control multiple characters)

SELECT * FROM score WHERE sname LIKE 'big _'; (_ a control character)

SELECT * FROM score WHERE sname LIKE '__'; (two characters)

 

Aggregate queries: (maximum value) SUM (sum) AVG (average) max min (minimum) COUNT (total number of records)

SELECT SUM(js) FROM score WHERE sclass='j1018';

SELECT AVG(html) FROM score WHERE sclass='JAVA-1018';

SELECT MIN(html+js+jquery) FROM score;

SELECT COUNT (*) FROM score; (total statistics do less data: Each column count it, whichever is greater)

 

Sentenced empty function

IFNULL(html,0);

 SELECT MIN(IFNULL(html,0)+js+jquery) FROM score;

 

Guess you like

Origin www.cnblogs.com/l1314/p/11961373.html