Another way of writing instead of LIKE in SQL

xiaoxiao2021-03-06  110

For example, find all users with "c", you can use

Use mydatabase

Select * from table1 where username like '% c%

Here is another way to complete the above functions:

Use mydatabase

Select * from Table1 WHERE Charindex ('C', UserName> 0

This method is theoretically than the previous method, that is,> 0, but this judgment process is the fastest, I want to believe that more than 80% of the operation is looking for words.

Strings and other operations, so it is not very much in use with the charIndex function. It is also good to use this method, that is,%, | Wait without direct use of Like

You can use it directly in this CharIndex in the character, as follows:

Use mydatabase

Select * from table1 where charIndex ('%', username)> 0

You can also write:

Use mydatabase

Select * from Table1 Where CHARINDEX (Char (37), UserName> 0

ASCII characters are%

转载请注明原文地址:https://www.9cbs.com/read-104089.html

New Post(0)