MySQL command learning (2) (13) where sentence operator
= Equal
<> Not equal
! = Not equal
<Less
> Greater
> = Greater than or equal
BETWEEN is BETWEEN two specified values.
For example:
Find the student records between 0007 and 0009 (excluding 0009 )?
SELECT * FROM student_info WHERE stu_id BETWEEN 1001101620007 AND 1001101620009;
(14)AndOperator
To filter by more than one column, you can use the and operator to add conditions to where statements.
For example:
Find out the student records of male students whose major is "software engineering" and whose gender is gender?
SELECT * FROM student_info WHERE stu_sex = 'male' AND stu_major = 'software project ';
(15)OROperator
Indicates MySQL to retrieve rows matching any condition
For example:
Find out all student records whose major is "network engineering" and "electronic information?
SELECT * FROM student_info WHERE stu_major = 'electronic information' OR stu_major = 'network project ';
Find the student records of all boys in "Network Engineering" and "software engineering?
SELECT * FROM student_info WHERE (stu_major = 'network Project' OR stu_major = 'software Project') AND stu_sex = 'male ';
(16)INOperator
Is used to specify the condition range. each condition IN the range can be matched. the list of valid values of IN is separated by commas (,), and all values are enclosed IN parentheses.
For example:
Find the student records for the specified three student IDs?
SELECT * FROM student_info WHERE stu_id IN (1001101620007,1001101650018, 1001101650019 );
(17)
NOTOperator
The function is to deny any conditions followed by it.
For example:
Find out the student records that are not "network engineering" or "software engineering?
SELECT * FROM student_info WHERE stu_major not in ('software project', 'network Project ');
(18)LIKEOperator
Special characters used to match a part of a value
% Wildcard indicates the number of times any character appears
_ Wildcard indicates that any character appears only once
For example:
Find out all student records with the last two words "engineering" in the professional name?
SELECT * FROM student_info WHERE stu_major LIKE '% project ';
Find the student record with the surname "Wang" and the name is two words?
SELECT * FROM student_info WHERE stu_name LIKE 'Wang _';