Conditions inquiry
1, Comparative query (>, <,> =, <=, =) Note: SQL query statement equal sign (=)
Student's name and gender (1) Student query table older than 18 years
select name,gender from students where age>18;
(2) Student query table is equal to 18 years older than the student's name and gender
select name,gender from students where age>=18;
(3) Student query table is equal to the age of 18-year-old student's name and gender
select name,gender from students where age=18;
2, logical query (and or not)
(1) queries older than 18 years old and is a student information girls;
select * from students where age>18 and gender=2;
(2) query older than 18 years of age or height equal to 180 student information;
select * from students where age>18 or height=180;
(3) Student Information Query is not within the scope of the girls over the age of 18;
select * from students where not (age>18 and gender=2);
(4) Query age is not less than or equal to 18-year-old girl and a student information;
select * from students where not (age<=18 )and gender=2;
3, fuzzy query
(1)like
% (Wildcard) --- represents 0 or more characters;
_ (Wildcard) --- represents a character;
To 'small' start student information query table name;
select * from students where name like '小%';
Lookup table names with 'small' student information;
select * from students where name like '%小%';
Lookup table names with the word of student information;
select * from students where name like '__';
Lookup table name at least two words of student information;
select * from students where name like '__%';
(2) rlike
Regular Expressions
. Represent a single character;
* To the previous character zero or infinite extension;
^ Start of the string;
$ End of the string;
Greed mode : as much as possible match (default)
Lazy Mode : Match as little as possible, the precise mode
If the combination of the following occurs, representatives Lazy mode :
*?
+?
Query name with 'Week' begins;
select * from students where name rlike '^周';
Query with 'Week' begins with 'London' end of the name;
select * from students where name rlike '^周.*伦$';