SQL Basics & Practice Questions
SQL (Structured Query Language) is used to store, manage, and retrieve data from relational
databases.
Key Commands:
- SELECT → Retrieve data
- WHERE → Apply conditions
- ORDER BY → Sort data
- GROUP BY → Group rows
- JOIN → Combine tables
- INSERT → Add data
- UPDATE → Modify data
- DELETE → Remove data
Sample Practice Questions
1. Get all student names and ages from 'students' table.
SELECT name, age FROM students;
2. Find all employees who earn more than 50,000.
SELECT * FROM employees WHERE salary > 50000;
3. Count how many students are in each department.
SELECT department, COUNT(*) FROM students GROUP BY department;
4. Show student names with their enrolled course names (using JOIN).
SELECT s.name, c.course_name FROM students s INNER JOIN courses c ON
s.course_id = c.id;
5. Increase salary of employee with id=101 by 10%.
UPDATE employees SET salary = salary * 1.10 WHERE id = 101;