Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SQL Query to Match City Names Ending With Vowels

  • Last Updated : 23 Sep, 2021

In this article, we will learn SQL Query How to Write an SQL Query to Match City Names Ending With Vowels in the Table. and we will implement with the help of an example for better understanding, first of all, we will create a database Name of the Database will Sample. and inside the database, we will create a table name As “office”.

Step 1: Create a Database

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

For database creation, there is the query we will use in SQL Platform. this is the query.

Query:



Create database sample;

Step 2: Use database

For using the database we will use another query in SQL Platform like Mysql, oracle, etc.

Query:

use Sample;

Step 3: Creation of table in Database

 For the creation of a table in a database. We need to execute a query in SQL. So that we can store Records in the table. 

Syntax:

create table table_name(
column1 type(size),
column2 type(size),
.

columnN type(size)
);

 Query:

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



Above Query will create a table in our database Sample. Here table name is office. After the creation of the table, we can Justify the view and metadata of the table with the help of the below Query. It will return Schema, column, data type, size, and constraints.

Syntax: 

EXEC sp_help table_name

Query:

EXEC sp_help office; 

Output:

EXEC sp_help table_name; Query is Similar as DESC table_name; query in another platform like Oracle, MySql, etc.

Step 4: Insert Data into a table

To insert data into the table there is the query we will use here in the SQL server.

Query:

INSERT INTO office
VALUES ('VISHAL','SALES',9193458625,'GAZIABAD'),
('VIPIN','MANAGER',7352158944,'BARIELLY'),
('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,'Dehli');

Step 5: View Inserted data 



After inserting data into the table We can justify or confirm which data we have to insert correctly or not. With the help of the below query.

Query:

SELECT * FROM office;

 Output:

Step 6: Query for matching city end with vowels

Query:

SELECT EMPNAME,CITY FROM office
WHERE CITY LIKE '%a'
OR CITY LIKE '%e'
OR CITY LIKE '%i'
OR CITY LIKE '%o'
OR CITY LIKE '%u';

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!