D
D
Dmaw2020-06-23 15:21:48
MySQL
Dmaw, 2020-06-23 15:21:48

How to find all 555 excluding any digit after?

How to find all 555 excluding any digit after?
After 555 there can be anything, if only not numbers, for example: Vova downloaded 555 games, Vova deleted programs555.
text LIKE '%555%'

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mletov, 2020-06-23
@mletov

Here is a collective farm, but universal solution.
For a more beautiful one, you need to know what kind of server you have (MSSQL, MySQL, etc.)

SELECT *
FROM table
WHERE text LIKE '%555%' 
AND NOT (
  text LIKE '%5550%' 
  OR text LIKE '%5551%' 
  OR text LIKE '%5552%' 
  OR text LIKE '%5553%' 
  OR text LIKE '%5554%' 
  OR text LIKE '%5555%' 
  OR text LIKE '%5557%' 
  OR text LIKE '%5557%' 
  OR text LIKE '%5558%' 
  OR text LIKE '%5559%'
)

PS: I still don't understand, there shouldn't be any numbers or only '5555'. If the latter, then take Lentyuy's solution

L
Lazy @BojackHorseman MySQL, 2020-06-23
Tag

AND NOT text LIKE '%5555%'

D
d-stream, 2020-06-23
@d-stream

Assuming MS SQL, you can use the option "any character, but not five":
like %555[^5]%
, although in a pure version it is worth beating at the beginning and end of the string - that is, there will be no character before / after and "555z" or "abcde555" - will not be caught.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question