当前位置:网站首页>SQL server requires to query the information of all employees with surname 'Wang'

SQL server requires to query the information of all employees with surname 'Wang'

2022-04-23 19:08:00 Little brother

For recent projects, the last name is required to be queried ‘ Li ’ Employee information , According to what I learned earlier LIKE '% millet %' This statement , Query all the content about Xiaomi , also

It's called fuzzy query .

%: Represents any string length

_: Represents the length of a single string

Because the surname Li can't all be 2 A word Li X, It could be 3 A word Li XX, So we can't use LIKE '_ Li _' , But to use. LIKE '% Li %'

And what we want to check is the surname Li, not the name related to li , therefore LIKE '% Li %' To write LIKE ' Li %'

select * from Table WHERE Name like ' Li %'

So all the people surnamed Li have been found out .


summary :

LIKE '% Li %' Li Add... Around the word % Express ‘ Li ’  word There can be words on the left , There can also be words on the right , You can also have words on only one side or no words at all , This is

                         Is to query all and Li Word related content .

LIKE ' Li %' Li Add... To the right of the word % Express Li ’  word There can be words or no words on the right , This is the query to Li word Content at the beginning

LIKE '% Li ' Li Add... To the left of the word % Express Li ’  word Left The side can have words or no words , This is the query to Li word Ending content

版权声明
本文为[Little brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210601423166.html