Unit 3 Database - Implementation - SQL FROM, ORDER BY and WHERE Flashcards
What does the FROM clause do?
It states which table or tables to get the data from.
What is the syntax of the FROM clause?
FROM table1, table2, …
What does the WHERE clause do?
It filters the data based on specified conditions.
What is the syntax of the WHERE clause?
WHERE column1 comparator1 value1 AND|OR column2 comparator2 value2 …
What does the equal sign (=) do in SQL?
It matches a value exactly. Example: WHERE userid = 70000.
What does the less than (<) operator do?
It selects values smaller than the given value. Example: WHERE customerid < 3938.
What does the greater than (>) operator do?
It selects values greater than the given value. Example: WHERE customerid > 500.
What does the AND operator do in SQL?
It ensures both conditions must be true. Example: WHERE customerid < 3938 AND userid = 70000.
What does the OR operator do in SQL?
It ensures at least one condition must be true. Example: WHERE customerid < 3938 OR userid = 70000.
What does the ORDER BY clause do?
It sorts the results of a query based on specified columns.
What is the syntax of the ORDER BY clause?
ORDER BY column1 ASC|DESC, column2 ASC|DESC, …
What happens if no sorting order is specified in ORDER BY?
Data is automatically sorted in ascending (ASC) order.
How does ORDER BY sort numbers?
Lowest at the top and highest at the bottom.
How does ORDER BY sort letters?
A at the top and Z at the bottom.
How can you sort by one column?
Example: SELECT * FROM hairdresser ORDER BY hairdresserid DESC.
How can you sort by multiple columns?
Example: SELECT * FROM client ORDER BY hairdresserid DESC, phonenumber ASC.