Skip to content
Advertisement

Get rows which contain exactly one special character

I have a SQL query which returns some rows having the below format:

How can i filter to get rows which only have the format of ‘DB_host’ (place a condition to return values with only one occurrence of ‘_’)

i tried using [0-9a-zA-Z_0-9a-zA-Z], but seems like its not right. Please suggest.

Advertisement

Answer

One option would be using REGEXP_COUNT and at most one underscore is needed then use

or strictly one underscore should exist then use

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement