Home >Daily Programming >Mysql Knowledge >What is the usage of is, between, in and other operators in PHP?

What is the usage of is, between, in and other operators in PHP?

慕斯
慕斯Original
2021-06-28 16:31:216422browse

We have learned so much about PHP, but I wonder what your usage of is, between, in and other operators in PHP is? Have you fully mastered it? If not, then follow this article to continue learning

Related recommendations:How to use additions, deletions, and modifications in PHP?

is operator: Judgment of null value and Boolean value

There are 4 situations to use:

  • xx is null: judge that a certain field is a "null" value - that is, there is no value, xxis not null: judge that a certain field is not a "null" value

  • xx is true: Judge a certain field as "true"

  • ##xxis false: Judge a certain field as "false" (false): o, 0.0, ". null

  • The so-called Boolean value is actually an "alias" of the tinyint(1) type. In essence, it just determines whether a number is 0

between operator: range judgment

is used to judge whether the data value of a certain field is within a given range - suitable for numeric types,

Syntax:

xxbetween值1and值2,含义:
XX字段的值在给定“值1”和“值2”之间,其实相当于:XX=值1 and xx <=值2;

in operator: given the range judgment of certain data

Syntax:

xxin(值1,值2,值3,...-.);含义﹔

means that the value of field XX is One of the listed values ​​​​is considered to have met the conditions; these values ​​are usually scattered and irregular.

If the data it lists has certain rules, it can actually be used Logical operator or between operator instead.

like operator: fuzzy search on string

Syntax:

xX     like‘要查找的内容"

Common examples and meanings:

name like "%罗%": Represents all data rows with the word "罗" in nam,

name like "Luo%xin: Represents all data rows starting with "Luo" in nam, such as: Roland,

name like "%Luo"; Represents all data rows ending with "Luo" in nam; for example: c Luo, Contra

namelike·Luo_": Represents all data lines in nam that begin with "Luo" and have only 2 characters, such as: Luo Lan

name like·_Luo ": Represents all data lines in nam that end with "Luo" and have only 2 characters, such as: c Luo

A new question:

If I want to find a certain What should I do if the lines containing "%"" in the field? Escape is ok:

%: represents the character % itself

L_: represents the character _ itself. Example ;

xX like "%9i% " ;

represents all lines containing the percent sign (%〉) in XX,

Related learning recommendations:

mysql tutorial(video)

The above is the detailed content of What is the usage of is, between, in and other operators in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn