SQL from Learning SQL Flashcards
(20 cards)
What SQL keyword is used to retrieve data from a table?
SELECT
Which clause filters rows from the result set based on a condition?
WHERE
How do you select all columns from a table named ‘products’?
SELECT * FROM products;
What symbol is used for equality in SQL conditions?
=
How would you retrieve only the ‘name’ and ‘price’ columns from a table called ‘items’?
SELECT name, price FROM items;
Which clause is evaluated before SELECT in query execution?
FROM
What is the default order of results returned by a SQL query?
Unordered (unless ORDER BY is used)
Which clause is used to sort results in ascending or descending order?
ORDER BY
How would you sort a query result by the ‘name’ column in descending order?
ORDER BY name DESC
What is the keyword to eliminate duplicate rows from a SELECT statement?
DISTINCT
What is the correct order of SQL clauses in a SELECT query?
SELECT, FROM, WHERE, ORDER BY
Which clause determines which table the data is coming from?
FROM
True or False: SQL queries are case-sensitive.
False
Which wildcard character is used in a LIKE clause to match any sequence of characters?
%
How do you retrieve all products where the name starts with ‘A’?
SELECT * FROM products WHERE name LIKE ‘A%’;
Which clause is used to filter rows that meet multiple conditions?
WHERE with AND/OR
How do you write a condition to find rows where ‘price’ is greater than 100?
WHERE price > 100
What does the BETWEEN operator do in SQL?
Selects values within a given range
How would you find all products priced between 10 and 50?
SELECT * FROM products WHERE price BETWEEN 10 AND 50;
Which SQL clause must appear last in a SELECT statement?
ORDER BY