Ollie Ollie - 6 months ago 15
SQL Question

SQL Strings that begin and end with Vowels - Looking for Shortcut

I have a newbie question regarding SQL. Is it possible to query a column in a table for strings that begin and end with vowels. I understand I can do the following....

SELECT ColumnName
FROM Table
WHERE ColumnName LIKE 'A%a' or 'E%a' or 'I%a' or 'O%a' or 'U%a' or
'A%e' or 'E%e' or 'I%e' or 'O%e' or 'U%e'...........etc...........;


But it feels like there has to be a shortcut. I just don't know what it is.
Thank you!!

vkp vkp
Answer

You can use REGEXP.

SELECT ColumnName
FROM Table
WHERE ColumnName REGEXP '^[aeiouAEIOU].*[aeiouAEIOU]$'