MySQL search: WHERE, mysql search where

Source: Internet
Author: User

MySQL search: WHERE, mysql search where

You can use the where condition to search by specifying a Search Condition in MySQL.

In a SELECT statement, data is filtered based on the conditions specified in the WHERE substatement. The WHERE substatement is given after the table name.

The product table is as follows:



A. Search for rows with a price equal to 2.50.


There are the following types of operators after the WHERE statement. With these operators, you can filter the corresponding conditions:

Operator Description
= Equal
<> Not equal
! = Not equal
< Less
<= Less than or equal
> Greater
> = Greater than or equal
BETWEEN Between two values

B character search



C search for all products with prices less than 10:



D. Search value range



I want to sort and display the results after the search, but this does not seem to work. It may be that after SELECT, only one clause can be followed:



Mysql advanced Query

Stored Procedure:
Drop procedure if exists p_1;
DELIMITER $
Create procedure 'mysql'. 'P _ 1 '()
BEGIN
DECLARE num int default 0;
Select COUNT (*) INTO num from TableName where department Name = Department and Time BetWeen Time 1 and Time 2;

IF num> 0 THEN
// Exact Query
ELSE
// Fuzzy search
End if;

END $

DELIMITER;

MYSQL statement. If you want to search for a field that contains a string, how can you write it?

Select * from table where A like '% BBB %' and condition; execute the following SQL statement to check whether the returned value exists.

Update table set A = replace ('bbb ', '', A) where A like' % BBB % 'and condition;

Oh ..
In this case, we can only extract it and split it into Arrays for judgment.

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.