



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of various SQL queries, including the use of WHERE, ORDER BY, ARITHMATIC, DISTINCT, ALTER, DROP, TRUNCATE, RENAME, SHOW, UPDATE, DELETE, and aggregate functions. It also covers independent and correlated subqueries and different types of joins. This resource is ideal for computer science, information technology, or database management students.
What you will learn
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!
SELECT * FROM management
WHERE name= 'Ramesh'; SELECT * FROM management
WHERE name LIKE = ’R%’; SELECT * FROM bran
WHERE city IN ('Solapur','Delhi'); SELECT * FROM management
WHERE name='Ramesh' AND (man_id>2002 OR man_id<2004); SELECT * FROM management
WHERE man_id BETWEEN 2001 AND 2003; 2-> ORDER BY SELECT * FROM customer ORDER BY Cus_Name DESC; 3->ARITHMATIC OPr SELECT * ,Bill-0.05*Bill AS Discounted_bill FROM portal
; 4-> DISTINCT SELECT DISTINCT name FROM management
; 5-> ALTER If we want to add column. ALTER TABLE management ADD COLUMN man_id int(5) NOT NULL; Only if we have to change constraint, ALTER TABLE management ADD UNIQUE KEY(man_id); For changing column name, datatype and constraint ALTER TABLE management CHANGE COLUMN man_id manager_id INT(12) ADD PRIMARY KEY(manager_id); If we want to change column datatype ,its size or constraints without changing column name ALTER TABLE management MODIFY COLUMN man_id int(5) UNIQUE KEY; 6-> DROP DROP TABLE Courier;
DROP COLUMN Courier.Cou_id; 7-> TRUNCATE TRUNCATE TABLE Management; 8-> RENAME RENAME TABLE management TO manager; 9-> SHOW SHOW CREATE TABLE management; 10-> Updating UPDATE courier SET type=’Light weight’, weight= WHERE cou_id=5003; 11-> Delete DELETE courier WHERE cou_id=5003; 12-> Aggregate functions MAX(col_name) MIN(col_name) COUNT(col_name) SUM(col_name) AVG(col_name) select max(weight) as max_weight,min(weight) as min_weight, SUM(weight) as Total_weight,count(type) as COUNT_Type ,count(distinct branch_id) as Dis_branch_id from courier SELECT MIN(weight) FROM courier; 13-> Other funs SQRT(col_name) ROUND(weight,2) UPPER(col_name) / UCASE(col_name) LOWER(col_name) / LCASE(col_name) MID(col_name,start,length) Ex:- MID(city,1,3) ->> Delhi:Del LENGTH(col_name) CONCAT(col_name1,col_name2,…..) REVERSE(col_name) NOW()
SELECT * FROM table_1 INNER JOIN table 2 ON table1.col_name <> table2.col_name; SELECT * FROM customer INNER JOIN courier ON customer.cus_id <> courier.cus_id; NATURAL JOIN SELECT * FROM table NATURAL JOIN table2; SELECT * FROM customer NATURAL JOIN courier; OUTER JOIN LEFT OUTER JOIN SELECT * FROM table LEFT JOIN table ON table1.col_name=table2.col_name SELECT * FROM tracking LEFT JOIN receiver ON receiver.rec_id=tracking.rec_id RIGHT OUTER JOIN
SELECT * FROM table RIGHT JOIN table ON table1.col_name=table2.col_name SELECT * FROM tracking RIGHT JOIN receiver ON receiver.rec_id=tracking.rec_id SELF JOIN SELECT * FROM table1 alias_name Inner JOIN table1 alias_name ON alias_name1.col_name= alias_name2.col_name; SELECT * FROM management m INNER JOIN management m ON m1.man_id=m2.man_id