Which comparison operator means 'not equal to' in SQL?
Explanation:
Both '!=' and '<>' are used for 'not equal to' in SQL. They are interchangeable.
Which SQL statement is used to add new rows into a table?
Explanation:
The INSERT statement is used to insert new rows with data into an existing table within a database.
In which scenario would a subquery be a more suitable choice than a JOIN operation?
Explanation:
Subqueries excel at providing dynamic filtering conditions for the main query. If the filtering relies on a separate query's results, using a subquery makes the logic clearer and more concise than attempting to achieve the same with JOINs.
What is the key difference between the IN and EXISTS operators when used with subqueries?
Explanation:
IN compares a value against a list of values returned by a subquery. EXISTS checks whether the subquery returns any rows at all, regardless of the values.
By default, how does the 'ORDER BY' clause sort data?
Explanation:
If no specific order (ASC or DESC) is specified, ORDER BY defaults to sorting in ascending order.
What type of join returns all rows from both tables, regardless of whether there is a match?
Explanation:
A FULL OUTER JOIN
returns all rows from both the left and right tables. If there are no matches on one side, it fills in NULL
values for the corresponding columns.
What is the purpose of the 'LIMIT' clause in SQL?
Explanation:
LIMIT is used to control how many rows are included in the query result, helping manage the amount of data returned.
In a SQL query, what does the logical operator 'AND' do?
Explanation:
The AND operator requires both conditions to be true for the combined condition to be true.
Which aggregate function would you use to find the highest value in a column?
Explanation:
MAX()
is an aggregate function that returns the maximum value in a set of values (typically a column).
What does SQL stand for?
Explanation:
SQL stands for Structured Query Language. It's a standardized language for managing and interacting with relational databases.
You are using a subquery to fetch a list of product IDs from an 'Orders' table. What is the main purpose of using the DISTINCT keyword within this subquery?
Explanation:
The DISTINCT keyword ensures that the subquery's result set contains only unique values, removing any duplicate product IDs, which is essential for accurate comparisons or joins in the main query.
What SQL clause is used to filter rows in a result set based on specific conditions?
Explanation:
The WHERE clause is used to specify conditions that rows must meet to be included in the query results.
Which keyword is used in conjunction with the UPDATE statement to specify the conditions for updating rows?
Explanation:
The WHERE clause is crucial with UPDATE as it defines which rows should be modified. Without it, all rows would be updated.
What does the asterisk (*) symbol represent when used in a SELECT statement?
Explanation:
In SQL, the asterisk (*) is a shorthand to select all columns from a table when used in the SELECT clause.
What SQL clause is used to group rows with the same value in one or more columns into a summary row?
Explanation:
The GROUP BY clause is specifically designed to group rows based on identical values in specified columns, allowing for aggregate functions to be applied to each group.