Open In App

SQL Query to Match City Names Ending With Vowels (a,e,i,o,u)

Last Updated : 10 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To match the names of cities ending with a vowel, use the LIKE operator with % wildcard. This matches all cities that end with a vowel.

Here is a SQL query to match city names ending with vowels (a,e, i,o,u).

Query:

SELECT EMPNAME,CITY
FROM office
WHERE CITY LIKE %[aeiou]

Example Database

To use this query, you need to create an example database and table. Here is how you can do it:

MySQL
CREATE DATABASE Sample;
USE Sample;

CREATE TABLE office
(
    EMPNAME VARCHAR(25),
    DEPT VARCHAR(20),
    CONTACTNO BIGINT NOT NULL,
    CITY VARCHAR(15)
);

INSERT INTO office
VALUES
    ('VISHAL', 'SALES', 9193458625, 'GHAZIABAD'),
    ('VIPIN', 'MANAGER', 7352158944, 'BAREILLY'),
    ('ROHIT', 'IT', 7830246946, 'KOLKATA'),
    ('RAHUL', 'MARKETING', 9635688441, 'MEERUT'),
    ('SANJAY', 'SALES', 9149335694, 'MORADABAD'),
    ('ROHAN', 'MANAGER', 7352158944, 'BENGALURU'),
    ('RAJESH', 'SALES', 9193458625, 'VODODARA'),
    ('AMAN', 'IT', 78359941265, 'RAMPUR'),
    ('RAKESH', 'MARKETING', 9645956441, 'BOKARO'),
    ('VIJAY', 'SALES', 9147844694, 'DELHI');

Output

Running this query will return the city names that end with vowels:

City Names Ending with Vowels
City Names Ending with Vowels

Conclusion

This SQL query helps you match city names ending with vowels. By using the LIKE operator with % wildcard, you can easily identify city names that end with vowels.


Similar Reads