0% found this document useful (0 votes)
11 views

Assignment 2

Uploaded by

rohit rajput
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Assignment 2

Uploaded by

rohit rajput
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE DATABASE Assignment_2;

USE Assignment_2;

DROP TABLE Customer;

-- 1. Create a customer table which comprises of these columns: ‘customer_id’,


‘first_name’, ‘last_name’, ‘email’, ‘address’, ‘city’,’state’,’zip’

CREATE TABLE Customer


(C_Id INT PRIMARY KEY,
First_Name VARCHAR(25) NOT NULL,
Last_Name VARCHAR(25) NOT NULL,
C_Email VARCHAR(30) NOT NULL,
C_Address VARCHAR(20) NOT NULL,
C_City VARCHAR(15) NOT NULL,
C_State VARCHAR(15) NOT NULL,
C_ZIP VARCHAR(10) NOT NULL);

-- 2. Insert 5 new records into the table

INSERT INTO Customer (C_Id, First_Name, Last_Name, C_Email, C_Address, C_City,


C_State, C_ZIP)
VALUES
(001, 'Bankim', 'Chaterjee', '[email protected]', 'Dumdum',
'Kolkata', 'West Bengal', 700028),
(002, 'Jose', 'Batista', '[email protected]', 'Retiro', 'Madrid',
'Madrid', 055430),
(003, 'Gilly', 'Adams', '[email protected]', 'Japantown', 'San Jose',
'California', 140596),
(004, 'Bhagat', 'Singh', '[email protected]', 'N.M.Town', 'Jalandhar',
'Punjab', 144001),
(005, 'Krishna', 'Duvvada','[email protected]', 'Vajrapukotturu',
'Srikakulam', 'Andhra Pradesh', 532222);

-- 3. Select only the ‘first_name’ and ‘last_name’ columns from the customer
table

SELECT First_Name, Last_Name


FROM Customer;

-- 4. Select those records where ‘first_name’ starts with “G” and city is ‘San
Jose’.

SELECT *
FROM Customer
WHERE First_Name LIKE 'G%'
AND
C_City= 'San Jose';

-- 5. Select those records where Email has only ‘gmail’.

SELECT *
FROM Customer
WHERE C_Email LIKE '%gmail%';

-- 6. Select those records where the ‘last_name’ doesn't end with “A”.

SELECT *
FROM Customer
WHERE Last_Name NOT LIKE '%a';

You might also like