MySQL command learning (2) _ MySQL

Source: Internet
Author: User
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 _';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.