Learn coding with amol
PART= 15 SQL
hello my name is amol sharma or vineet and this is my 15th part of learn coding with amol and in this part we are going SQL basics to advance.
Complete SQL Tutorial (Beginner to Intermediate)
Author: Amol Sharma | learncodingwithamol.blogspot.com
1. What is SQL?
Definition: SQL (Structured Query Language) is used to create, read, update, and delete data in databases.
2. CREATE DATABASE
Definition: Creates a new database.
CREATE DATABASE school;
3. USE Database
Definition: Selects a database to work with.
USE school;
4. CREATE TABLE
Definition: Creates a table inside a database.
CREATE TABLE students ( id INT PRIMARY KEY, name VARCHAR(50), age INT );
5. INSERT INTO
Definition: Inserts new data into a table.
INSERT INTO students (id, name, age) VALUES (1, 'Amol', 17);
6. SELECT
Definition: Retrieves data from a table.
SELECT * FROM students;
7. WHERE
Definition: Filters records based on conditions.
SELECT * FROM students WHERE age > 16;
8. UPDATE
Definition: Updates existing records in a table.
UPDATE students SET age = 18 WHERE id = 1;
9. DELETE
Definition: Removes records from a table.
DELETE FROM students WHERE id = 1;
10. ORDER BY
Definition: Sorts records in ascending or descending order.
SELECT * FROM students ORDER BY age DESC;
11. LIMIT
Definition: Limits number of records returned.
SELECT * FROM students LIMIT 3;
12. AND / OR
Definition: Combines multiple conditions.
SELECT * FROM students WHERE age > 15 AND name = 'Amol';
13. COUNT()
Definition: Counts number of records.
SELECT COUNT(*) FROM students;
14. GROUP BY
Definition: Groups records with same values.
SELECT age, COUNT(*) FROM students GROUP BY age;
15. INNER JOIN
Definition: Combines rows from two tables using a common column.
SELECT students.name, marks.score FROM students INNER JOIN marks ON students.id = marks.student_id;
16. DROP TABLE
Definition: Deletes a table permanently.
DROP TABLE students;
17. Conclusion
SQL is a must-learn language for backend development, databases, and full-stack projects.

Comments
Post a Comment