0% found this document useful (0 votes)
6 views9 pages

Assignment 3 - 241114 - 092608

Uploaded by

parag.naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Assignment 3 - 241114 - 092608

Uploaded by

parag.naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment 3

NAME: Abhishek Kumbhar


PRN: 202101070059
BATCH: 2

CREATE DATABASE sales;

USE sales;

CREATE TABLE sales.customers (

customer_id INT AUTO_INCREMENT PRIMARY KEY,

first_name VARCHAR(15),

last_name VARCHAR(15),

age INT NOT NULL,

country VARCHAR(10) NOT NULL

);

SHOW DATABASES;

SHOW TABLES;

INSERT INTO sales.customers

(first_name, last_name, age, country)

VALUES

("JHON","DOE",31,"USA"),

("ROBERT","LULLA",22,"USA"),

("DAVID","ROBIMSON",22,"UK"),

("JOHN","REINHARDT",25,"UK"),

("BETTY","DOE",28,"UAE");

SELECT * FROM sales.customers;


SELECT first_name,last_name FROM customers; #showing only two columns

SELECT * FROM sales.customers

WHERE last_name = 'DOE';

SELECT * FROM sales.customers

WHERE last_name = 'DOE' AND country='UAE';

SELECT * FROM sales.customers

WHERE NOT country = 'USA';

SELECT * FROM sales.customers

WHERE (country='USA' or country='UK') AND age=25;

SELECT * FROM sales.customers

WHERE age>25;

SELECT DISTINCT country FROM sales.customers;

SELECT COUNT(DISTINCT country)

FROM sales.customers;

SELECT f_name as first_name, l_name as last_name

FROM sales.customers;

SELECT c.first_name, c.age

FROM customers as c;

SELECT * FROM customers;


# Combining the two columns

SELECT CONCAT(first_name, ' ', last_name) AS full_name, customer_id

FROM customers;

SELECT first_name, last_name FROM customers LIMIT 3; #print 1st three columns

SELECT * FROM custommers

LIMIT 3 OFFSET 3;

# bellow both the query will give same result

SELECT first_name, country FROM customers

WHERE country = 'USA';

SELECT first_name, country FROM customers

WHERE country IN ('USA','UK');

SELECT * FROM customers;

SELECT * FROM customers

WHERE last_name = 'LUNA'

LIMIT 1;

SELECT * FROM customers

WHERE first_name= 'JHON' and age=31;

SET SQL_SAFE_UPDATES=0;

UPDATE customers
SET first_name ='DAVID1'

WHERE first_name = 'DAVID';

SELECT * FROM customers;

SELECT * FROM customers

WHERE first_name REGEXP '[0-9]';

You might also like