JOIN combines rows from two or more tables based on a relationship between the columns (usually foreign key relationship).
INNER JOIN returns only the rows that have matching values in both tables being joined.
The ORDER BY clause sorts the result set in ascending (ASC) or descending (DESC) order. Default is ascending.
WHERE filters individual rows before GROUP BY is applied, while HAVING filters the grouped results after GROUP BY is applied.
The AND operator requires both conditions to be true, so only employees in IT department with salary > 50000 are returned.
COUNT(column_name) counts the number of non-NULL values in the specified column. COUNT(*) counts all rows.
PRIMARY KEY ensures uniqueness and prevents NULL values in a column, uniquely identifying each row in a table.
The underscore (_) wildcard matches exactly one character, while % matches zero or more characters.
# SQL Statement for Deleting Records While Preserving Table Structure
Understanding the differences between SQL commands for removing data versus removing entire tables is essential for database management.
## Step 1: Identify the Requirement
The question asks for a command that removes ALL records from a table but keeps the table structure (columns, constraints, indexes) intact.
## Step 2: Analyze Each Option
| Option | Command | Effect | Table Structure |
|--------|---------|--------|-----------------|
| (A) | DELETE FROM | Removes rows one by one (slower) | ✓ Preserved |
| (B) | DROP TABLE | Removes entire table including structure | ✗ Deleted |
| (C) | TRUNCATE TABLE | Removes all rows at once (faster) | ✓ Preserved |
| (D) | REMOVE FROM | Not a valid SQL command | N/A |
## Step 3: Why TRUNCATE is Superior
TRUNCATE TABLE uses minimal transaction log space, resets identity seeds, and is faster than DELETE because it deallocates data pages rather than removing rows individually.
The correct answer is (C) TRUNCATE TABLE table_name; — it removes all records while preserving the table structure, indexes, and constraints.
SUM() and AVG() ignore NULL values. COUNT(*) counts all rows including those with NULLs, while COUNT(column) ignores NULLs.