In SQL Server, the Replace keyword is used primarily to replace a character in a string with another character, and today, in reverse thinking, it can also be used to query whether a particular string is included, for example, given the following dataset
Expect to get records containing "AAA" characters from this dataset, noting that the 2nd data does not contain "AAA", but rather "AAAA". The expected "" results are as follows:
The traditional mindset must be to figure out how to find a string containing 3 A, and some people will look like, but this will be done with 4 a. Here we think of replacing the "AAA" in the string with replace, and if it can be replaced, prove that the string contains this character, and replace it with the original string, so the following SQL is released.
SELECT * FROM [master]. [dbo]. [Table_5]
WHERE REPLACE (', ' +strnum+ ', ', ', AAA, ', ') <> ', ' +strnum+ ', '