Q1
True / FalseThe MySQL "NOT IN" clause can be used to exclude records that match any value in a list of specified values.
The "NOT IN" clause in MySQL is used to filter out records that do not match any value in the specified list.
Q2
True / FalseIn MySQL, the "NOT IN" clause can only be used with numerical values.
The "NOT IN" clause in MySQL can be used with both numerical and textual values.
Q3
True / FalseMySQL will return an empty result set if "NOT IN" is used with an empty list.
Using "NOT IN" with an empty list will not filter out any records, meaning all records will be returned.
Q4
True / False: In MySQL, "NOT IN" can be used with subqueries to filter out results from another table.
The "NOT IN" clause can be used in conjunction with subqueries to exclude records that match the results of the subquery.
Q5
True / FalseUsing "NOT IN" in MySQL is generally faster than using "NOT EXISTS" for the same purpose.
The performance of "NOT IN" vs. "NOT EXISTS" can vary depending on the context, but "NOT EXISTS" is often faster, especially with large datasets and complex subqueries.
Q6
True / FalseMySQL's "NOT IN" clause can handle NULL values without any issues.
If the list of values in the "NOT IN" clause contains a NULL, the entire comparison will return NULL, resulting in no rows being returned.
Q7
True / FalseIn MySQL, using "NOT IN" with a subquery that returns a NULL value will result in an empty result set.
If the subquery returns a NULL value, the "NOT IN" clause will not match any rows, effectively returning an empty result set.
Q8
True / FalseIn MySQL, "NOT IN" can be used in conjunction with JOIN operations to filter joined results.
NOT IN" can be used alongside JOIN operations to exclude records based on the joined table's values.
Q9
True / FalseUsing indexes in MySQL can improve the performance of queries using the "NOT IN" clause.
Indexes can enhance query performance, including those using "NOT IN", by reducing the amount of data that needs to be scanned.
Q10
True / FalseIn MySQL certification exams, you may be asked to optimize a query using "NOT IN" by considering alternative clauses like "NOT EXISTS" or "LEFT JOIN ... IS NULL".
Optimization is a key topic in MySQL certification, and understanding when to use "NOT IN" versus other options like "NOT EXISTS" or "LEFT JOIN ... IS NULL" is essential for improving query performance.
Q11
Single ChoiceWhich of the following MySQL queries will correctly select all rows where the country column is NOT 'USA', 'Canada', or 'Mexico'?
The NOT IN operator is used to exclude rows that match any value in the specified list.
Q13
Single ChoiceWhat does this query do?
SQL Code
Consider the following SQL code:
SELECT employee_id FROM employees WHERE department_id NOT IN (5, 7, 9);
The NOT IN operator is used here to exclude employees from the specified departments.
Q21
Multiple ChoiceWhich query correctly retrieves records from the 'employees' table where the 'department_id' is not in the list (1, 2, 3)?
SQL Code
SELECT *
FROM employees
WHERE department_id NOT IN (1, 2, 3);
The NOT IN operator is used to filter rows where the 'department_id' is not in the list of values (1, 2, 3).
Q22
Multiple ChoiceIdentify the correct SQL query that retrieves records from the 'products' table where 'category_id' is not in the list (5, 10, 15).
SQL Code
SELECT *
FROM products
WHERE category_id NOT IN (5, 10, 15);
The NOT IN operator filters rows where the 'category_id' does not match any of the values in the list (5, 10, 15).
Q23
Multiple ChoiceWhich query correctly selects records from the 'orders' table where the 'status' is not in ('Pending', 'Shipped', 'Delivered')?
SQL Code
SELECT *
FROM orders
WHERE status NOT IN ('Pending', 'Shipped', 'Delivered');
The NOT IN operator is used to filter rows where the 'status' does not match any of the specified values: 'Pending', 'Shipped', or 'Delivered'.
Q24
Multiple ChoiceDetermine the correct SQL query that retrieves records from the 'customers' table where 'country' is not in ('USA', 'Canada', 'Mexico').
SQL Code
SELECT *
FROM customers
WHERE country NOT IN ('USA', 'Canada', 'Mexico');
The NOT IN operator filters rows where the 'country' does not match any of the specified values: 'USA', 'Canada', or 'Mexico'.
Q25
Multiple ChoiceWhich SQL query retrieves records from the 'inventory' table where 'item_id' is not in the list (101, 102, 103)?
SQL Code
SELECT *
FROM inventory
WHERE item_id NOT IN (101, 102, 103);
The NOT IN operator is used to filter rows where the 'item_id' does not match any of the values in the list (101, 102, 103).
Q26
Multiple ChoiceIdentify the correct query that retrieves records from the 'employees' table where 'job_title' is not in ('Manager', 'Engineer', 'Analyst').
SQL Code
SELECT *
FROM employees
WHERE job_title NOT IN ('Manager', 'Engineer', 'Analyst');
The NOT IN operator filters rows where the 'job_title' does not match any of the specified values: 'Manager', 'Engineer', or 'Analyst'.
Q27
Multiple ChoiceWhich SQL query correctly retrieves records from the 'sales' table where 'region' is not in ('North', 'South', 'East')?
SQL Code
SELECT *
FROM sales
WHERE region NOT IN ('North', 'South', 'East');
The NOT IN operator filters rows where the 'region' does not match any of the specified values: 'North', 'South', or 'East'.
Q28
Multiple ChoiceDetermine the correct SQL query that selects records from the 'projects' table where 'status_id' is not in (2, 4, 6).
SQL Code
SELECT *
FROM projects
WHERE status_id NOT IN (2, 4, 6);
The NOT IN operator filters rows where the 'status_id' does not match any of the values in the list (2, 4, 6).
Q29
Multiple ChoiceWhich query correctly retrieves records from the 'users' table where 'role_id' is not in (1, 3, 5)?
SQL Code
SELECT *
FROM users
WHERE role_id NOT IN (1, 3, 5);
The NOT IN operator filters rows where the 'role_id' does not match any of the values in the list (1, 3, 5).
Q30
Multiple ChoiceIdentify the correct SQL query that retrieves records from the 'transactions' table where 'payment_method' is not in ('Credit Card', 'PayPal', 'Bank Transfer').
SQL Code
SELECT *
FROM transactions
WHERE payment_method NOT IN ('Credit Card', 'PayPal', 'Bank Transfer');
The NOT IN operator filters rows where the 'payment_method' does not match any of the specified values: 'Credit Card', 'PayPal', or 'Bank Transfer'.