SQL - Select Statement V1.0
Create a query with the LIMIT and OFFSET clauses to retrieve 10 rows starting from the 21st row from a table named 'customers'.
SELECT * FROM customers LIMIT 10 OFFSET 20;
Write a query using the WHERE clause to retrieve all rows from a table named 'customers' where the 'age' column is greater than 30.
SELECT * FROM customers WHERE age > 30;
Write a query using the SELECT statement to retrieve all columns from a table named 'employees'.
SELECT * FROM employees;
How can you use the ORDER BY clause to sort the result set in ascending order based on the 'date' column from a table named 'orders'?
SELECT * FROM orders ORDER BY date;
How can you limit the number of rows returned in a result set to 10 from a table named 'products'?
SELECT * FROM products LIMIT 10;
Write a query with the ORDER BY clause to sort the result set in descending order based on the 'price' column from a table named 'products'.
SELECT * FROM products ORDER BY price DESC;
Create a query with the WHERE clause to retrieve all rows from a table named 'products' where the 'category' column equals 'Electronics'.
SELECT * FROM products WHERE category = 'Electronics';
What is the purpose of the SET keyword in a DELETE statement?
There is no SET keyword in a DELETE statement
What is the purpose of the WHERE keyword in an INSERT statement?
There is no WHERE keyword in an INSERT statement
What is the purpose of the INSERT statement?
To add a new row into a table
What is the purpose of the UPDATE statement?
To modify existing data in a table
What is the purpose of the DELETE statement?
To remove rows from a table
What is the purpose of the SET keyword in an UPDATE statement?
To specify the column and its new value to be updated
What is the purpose of the WHERE clause in a DELETE statement?
To specify the condition for which rows to delete
What is the purpose of the WHERE clause in an UPDATE statement?
To specify the condition for which rows to update
What is the purpose of the FROM keyword in a DELETE statement?
To specify the table from which to delete the rows
What is the purpose of the VALUES keyword in an INSERT statement?
To specify the values to be inserted into the table
How can you update a specific column in a table?
UPDATE table_name SET column_name = new_value WHERE condition
What is the syntax for updating multiple rows in a table?
UPDATE table_name SET column_name = new_value WHERE condition
How can you insert a new row into a table named 'students' with values 'John' for the 'name' column and 25 for the 'age' column?
INSERT INTO students (name, age) VALUES ('John', 25);
What is the syntax for inserting a new row into a table?
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)
How can you delete a specific row from a table?
DELETE FROM table_name WHERE condition
Create a query with the SELECT statement to retrieve the 'name' and 'salary' columns from a table named 'employees'.
SELECT name, salary FROM employees;