Matty82
Matty82

Reputation: 67

MySQL regular expression issue

I have a varchar column "category" with several values:

1.1
1.1.1
2.1
2.2.2
3.1.2.1

Now I want to select all columns with only one "." (dot) in it's value. But "...WHERE category regexp '[.]{1}'..." does not work, even if I escape the "." with a backslash.

Thanks in advance. Matty

Upvotes: 0

Views: 16

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269763

Just use like:

where category like '%.%' and category not like '%.%.%'

Upvotes: 3

Related Questions