MySQL search: WHERE multi-condition, mysqlwhere

Source: Internet
Author: User

MySQL search: WHERE multi-condition, mysqlwhere

WHERE can be searched by multiple conditions.

The products table is as follows:



After a WHERE, search by and based on two conditions and three conditions:




B uses or to search for multiple conditions



C. Find out the products with a price greater than 10 produced by vend_id of 1002 or 1003. here we need to use and or for combination:


However, from the above results, this output is not correct because AND has a higher priority than OR. Therefore, this statement is used to retrieve all products with vend_id = 1002, for products with vend_id = 1003 and a price greater than 10, you need to use () to rewrite this sentence:



D. Use IN to show multiple search values. The function is similar to OR. However, when there are multiple values, the syntax for using IN is more intuitive.



The e NOT operator denies the following conditions:


IN MySQL, NOT can be used to retrieve reverse IN, BETWEEN, and EXISTS, which is different from other DBMS systems.


Mysql multi-condition Query

Select * from table name where Condition 1 and condition 2 and Condition 3

Maximum number of Where conditions in MySql

The length of the limit is unclear, but you can write it if it is enough.
 

Related Article

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.