Basic principles of query for PHP development query

Fuzzy query principle

sql statement

1. Use sql matching pattern, operator = cannot be used or! = , instead use the operator LINK or NOT LINK.

2. Using SQL matching mode, MYSQL provides two wildcard characters % represents any number of any characters (including 0)

_ represents any single character

3. Use SQL matching mode. If the matching box does not contain any of the wildcard characters in the above 2, the query effect is equivalent to = or! =

sql matching pattern

#Query users starting with a certain character

Query users starting with symbol l

1%

select*from user where username like 'l%';

#Query users ending with a certain character

Query users ending with symbol e

%e

select*from user where username like '%e';

#Query users that contain a certain character

Query users whose username contains the character '0'

%o%

select*from user where username like '%o%';

Query users whose user length is 3

___

select*from user where username like '___';

Combination of two wildcard characters

Query users whose second character is o User

_O%

select*from user where username like '_O%';

The fuzzy query statement uses the LIKE statement in the sql statement to query.

Continuing Learning
||
<?php //select*from user where username like 'l%'; //select*from user where username like '%e'; //select*from user where username like '%o%'; //select*from user where username like '___'; //select*from user where username like '_O%'; ?>
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!