0% found this document useful (0 votes)
0 views2 pages

SQL MySQL Quick Reference-1

This document is a practical SQL cheat sheet designed for Java Backend and DSA learners, covering essential SQL commands and concepts. It includes sections on database creation, data manipulation (insert, select, update, delete), filtering, sorting, aggregate functions, joins, and constraints. The document emphasizes a structured learning order and clarifies the distinction between SQL language, MySQL RDBMS, and MySQL Workbench tool.

Uploaded by

ddgytt589
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)
0 views2 pages

SQL MySQL Quick Reference-1

This document is a practical SQL cheat sheet designed for Java Backend and DSA learners, covering essential SQL commands and concepts. It includes sections on database creation, data manipulation (insert, select, update, delete), filtering, sorting, aggregate functions, joins, and constraints. The document emphasizes a structured learning order and clarifies the distinction between SQL language, MySQL RDBMS, and MySQL Workbench tool.

Uploaded by

ddgytt589
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

SQL + MySQL Quick Reference

Java Backend / DSA learner ke liye practical SQL cheat sheet

1. Database & Table Basics


CREATE DATABASE college;
USE college;

CREATE TABLE student (


id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);

2. Insert / Select
INSERT INTO student VALUES (1, 'Aman', 20);

SELECT * FROM student;


SELECT name, age FROM student;

3. Filtering & Sorting


SELECT * FROM student WHERE age > 18;
SELECT * FROM student WHERE age BETWEEN 18 AND 25;
SELECT * FROM student WHERE name LIKE 'A%';
SELECT * FROM student ORDER BY age DESC;
SELECT DISTINCT age FROM student;

4. Update / Delete
UPDATE student SET age = 21 WHERE id = 1;
DELETE FROM student WHERE id = 1;

5. Aggregate Functions
SELECT COUNT(*) FROM student;
SELECT SUM(age) FROM student;
SELECT AVG(age) FROM student;
SELECT MIN(age), MAX(age) FROM student;

6. GROUP BY & HAVING


SELECT age, COUNT(*)
FROM student
GROUP BY age
HAVING COUNT(*) > 1;
7. JOIN — Very Important
SELECT [Link], c.course_name
FROM student s
INNER JOIN course c
ON s.course_id = [Link];

Common JOINs
INNER JOIN → dono tables me matching rows
LEFT JOIN → left table ki sab rows + matching right rows
RIGHT JOIN → right table ki sab rows + matching left rows

8. Constraints / Keys
PRIMARY KEY → row ko uniquely identify karta hai
FOREIGN KEY → tables ke beech relationship
NOT NULL → value required
UNIQUE → duplicate values prevent karta hai
DEFAULT → default value deta hai

9. Important Learning Order


CREATE/USE → CREATE TABLE → INSERT → SELECT → WHERE → ORDER BY → DISTINCT →
UPDATE/DELETE → LIKE/IN/BETWEEN → COUNT/SUM/AVG/MIN/MAX → GROUP BY → HAVING → JOIN →
Subqueries

10. Quick Reminder


SQL language hai, MySQL RDBMS hai, aur MySQL Workbench GUI/tool hai. Is sheet ka goal SQL queries ko
practice karna hai—not theory ratna.

You might also like