Open In App

SQL Query to Match City Names Ending With Vowels

Last Updated : 25 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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

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,'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');

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:


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads