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

SQL_Practice_Queries

The document provides a series of SQL practice queries along with explanations for each. It includes examples of INSERT, SELECT, UPDATE, and DELETE operations on a Students table. Additionally, it demonstrates the use of WHERE, ORDER BY, and LIKE clauses, as well as inserting multiple rows in one query.

Uploaded by

hend mohamed
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_Practice_Queries

The document provides a series of SQL practice queries along with explanations for each. It includes examples of INSERT, SELECT, UPDATE, and DELETE operations on a Students table. Additionally, it demonstrates the use of WHERE, ORDER BY, and LIKE clauses, as well as inserting multiple rows in one query.

Uploaded by

hend mohamed
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/ 2

SQL Practice Queries with Answers

1. INSERT Query

INSERT INTO Students (ID, Name, Age, Major)

VALUES (1, 'Alice', 20, 'Computer Science');

Explanation: Inserts a new student record into the Students table.

2. SELECT Query

SELECT * FROM Students;

Explanation: Retrieves all columns for all records in the Students table.

3. SELECT with WHERE Clause

SELECT Name, Major FROM Students WHERE Age > 18;

Explanation: Selects the names and majors of students older than 18.

4. UPDATE Query

UPDATE Students SET Major = 'Data Science' WHERE Name = 'Alice';

Explanation: Updates Alice's major to Data Science.

5. DELETE Query

DELETE FROM Students WHERE ID = 1;

Explanation: Deletes the student with ID 1 from the table.

6. SELECT with ORDER BY

SELECT * FROM Students ORDER BY Age DESC;

Explanation: Selects all students and orders them by age in descending order.

7. SELECT with LIKE

SELECT * FROM Students WHERE Name LIKE 'A%';

Explanation: Selects all students whose names start with 'A'.


8. INSERT Multiple Rows

INSERT INTO Students (ID, Name, Age, Major)

VALUES (2, 'Bob', 22, 'Engineering'), (3, 'Carol', 19, 'Biology');

Explanation: Inserts multiple student records in a single query.

You might also like