EXAM PREP Flashcards
(9 cards)
How do you query data from multiple tables in SQL?
You can use a JOIN statement to combine data from multiple tables based on a related column between them, such as using INNER JOIN, LEFT JOIN, etc.
What is a CASE statement in SQL?
The CASE statement is used to create conditional logic within a query, allowing you to return different values based on conditions (similar to an IF-ELSE in programming).
How can you remove a substring from a string in SQL?
You can use the REPLACE or REGEXP_REPLACE function to remove specific substrings.
How do you delete records in a SQL table?
Use the DELETE FROM statement followed by a WHERE clause to specify which rows to remove. Without a WHERE clause, all rows will be deleted.
How do you update records in a SQL table?
Use the UPDATE statement along with the SET clause to modify values. You must include a WHERE clause to specify which rows to update.
What is the purpose of the GROUP BY clause in SQL?
The GROUP BY clause is used to group rows that have the same values in specified columns and allow aggregate functions (like SUM(), AVG()) to operate on those groups.
How can you format numbers with commas and decimal places in SQL?
You can use the FORMAT function to format numbers with commas and a specified number of decimal places. For example, FORMAT(price, 2) formats a price with two decimal places.
The SQL keyword INSERT …
adds rows to tables.