Home>Article>Database> How to use like in sql

How to use like in sql

hzc
hzc Original
2020-06-09 15:40:32 20759browse

How to use like in sql

Usage of like in sql:

The operator LIKE uses wildcards to compare a value with similar values. There are two wildcards:

1. Percent sign (%): represents zero, one or more characters

2. Underscore (_): represents a number or character

The condition matches any value that starts with 200

WHERE SALARY LIKE '200%'

The following condition matches any value that contains 200 (at any position)

WHERE SALARY LIKE '%200%'

The following condition matches the second and third characters that are 0 Value

WHERE SALARY LIKE '_00%'

The following condition matches values that start with 2 and have a length of at least 3

WHERE SALARY LIKE '2_%_%'

The following condition matches values whose second position is 2 and ends with 3

WHERE SALARY LIKE '_2%3'

Recommended tutorial: "sql tutorial"

The above is the detailed content of How to use like in sql. For more information, please follow other related articles on the PHP Chinese website!

sql
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