I have a column that's string and I would like to use a WHERE
statement for all strings that begin with the "sea_"
Any ideas on how to achieve that will be appreciated.
Thanks in advance
CodePudding user response:
It's not clear what exactly your where clause should do. If necessary, you should please add more information. Anyway, in general, you can do such a select:
SELECT column FROM table WHERE column LIKE 'sea_%'
The % means that zero, one or more characters can follow. If you need further conditions like an exact number of trailing characters etc., you please must specify your question.
CodePudding user response:
If you like to ignore Upper/Lower case , it can help you
SELECT * FROM table WHERE LOWER(column) LIKE 'sea_%'
CodePudding user response:
Be aware that underscore _
is itself a placeholder for any single character which must be escaped in order to use it literally.
The criteria you should use to ensure an underscore is also present is
where column like 'sea[_]%';
You can also define your own explicite escape character, such as
where column like 'sea@_%' escape '@';