SQL query to check if a name begins and ends with a vowel
You could use a regular expression:
SELECT DISTINCT city
FROM station
WHERE city RLIKE '^[aeiouAEIOU].*[aeiouAEIOU]$'
How to retrieve rows that begin and end with vowels?
You can use LEFT()
and RIGHT()
functions. Left(CITY,1)
will get the first character of CITY
from left. Right(CITY,1)
will get the first character of CITY
from right (last character of CITY
).
DISTINCT
is used to remove duplicates. To make the comparison case-insensitive, we will use the LOWER()
function.
SELECT DISTINCT CITY
FROM STATION
WHERE LOWER(LEFT(CITY,1)) IN ('a', 'e', 'i', 'o', 'u') AND
LOWER(RIGHT(CITY,1)) IN ('a', 'e', 'i', 'o', 'u')
Related Topics
How to Store Emoji Character in MySQL Database
Two Rows With the Same Id and Two Different Values, Getting the Second Value into Another Column
Fill a Field With the Values from Another Field in Ms Access
Use Current Date as Default Value for a Column
Remove Multiple Keys from Jsonb Column in One Statement
How to Convert Bigint (Unix Timestamp) to Datetime in SQL Server
Sql Select All Data That Past 45 Days
How to Have a Default Parameter for a MySQL Stored Procedure
Mysql - Operand Should Contain 1 Column(S)
How to Handle Duplicates Created by Left Join
Sql: Find Country Name of the Team Having the Most Players Who Have Never Scored a Goal
Sql Server How to Find the Customers Who Have Bought a Product from Each Store
Mysql Inner Join Select Only One Row from Second Table
How to Include Results of SQL Count If Count=0