Saravana Shankar
Saravana Shankar

Reputation: 71

Select query to get particular pattern

I have a column which stores the data from the below format. ["12973","111","5555"].

I want to select the items which is not in the above set. for ex,

If I search 12973 if it is exactly match it will not return. When I use Like if I search "129" it also return the same result.

Any ideas to solve this problem..

Upvotes: 0

Views: 43

Answers (2)

Marcus
Marcus

Reputation: 1930

What about search all results with LIKE and remove the exact matches?

SELECT * FROM t WHERE a LIKE '%129%' AND a != '129'

Upvotes: 0

Joakim Danielson
Joakim Danielson

Reputation: 51892

If you are searching for an exact number you can use NOT LIKE to exclude the row

SELECT * FROM test WHERE col1 NOT LIKE '%"12973"%'

if you are searching for a row where no numbers start with 129 you can use REGEXP

SELECT * FROM test WHERE NOT col1 REGEXP '.*"129[0-9]*"'

Upvotes: 1

Related Questions