0% found this document useful (0 votes)
15 views1 page

Assignment 2

Uploaded by

rohit rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Assignment 2

Uploaded by

rohit rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
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', 'bankim.chaterjee@yahoo.com', 'Dumdum',
'Kolkata', 'West Bengal', 700028),
(002, 'Jose', 'Batista', 'jose.batista@rediffmail.com', 'Retiro', 'Madrid',
'Madrid', 055430),
(003, 'Gilly', 'Adams', 'gilly_adams@gmail.com', 'Japantown', 'San Jose',
'California', 140596),
(004, 'Bhagat', 'Singh', 'bhagat.singh@gmail.com', 'N.M.Town', 'Jalandhar',
'Punjab', 144001),
(005, 'Krishna', 'Duvvada','jayakrishna@yahoo.com', '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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy