MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:Logical Operators
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, the logical operator AND returns true if both operands are true.

Q2
True / False

The OR logical operator in MySQL will return true if at least one of the operands is true.

Q3
True / False

In MySQL, the NOT logical operator negates the value of the condition it precedes.

Q4
True / False

MySQL's logical operators AND and OR have the same precedence level.

Q5
True / False

In MySQL, the expression NULL AND TRUE will return NULL.

Q6
True / False

The XOR operator in MySQL is used to return true if both operands are either true or both are false.

Q7
True / False

In MySQL, the logical operator AND can be short-circuited.

Q8
True / False

The precedence of logical operators in MySQL is NOT, AND, then OR.

Q9
True / False

In MySQL, combining AND and OR in a single query without parentheses will always produce predictable results.

Q10
True / False

In MySQL, using logical operators with subqueries in the WHERE clause can improve query performance.

Q11
Single Choice

What will the following SQL query return?

SQL Code
SELECT * FROM employees WHERE status = 'active' AND department = 'Sales';
Q12
Single Choice

Which logical operator would you use to combine conditions where at least one must be true?

Q13
Single Choice

How would you exclude records where the status is 'inactive'?

SQL Code
SELECT * FROM orders WHERE status <> 'inactive';
Q14
Single Choice

What will this SQL query return?

SQL Code
SELECT * FROM products WHERE price > 100 AND (category = 'Electronics' OR category = 'Appliances');
Q15
Single Choice

Which SQL statement will select records where status is not 'completed' or priority is 'high'?

SQL Code
SELECT * FROM tasks WHERE NOT (status = 'completed' AND priority = 'high');
Q16
Single Choice

What will be the result of the following SQL query?

SQL Code
SELECT * FROM orders WHERE amount > 50 AND amount < 150 AND (status = 'shipped' OR status = 'pending');
Q17
Single Choice

How would you use a logical operator to find employees who are either 'Manager' or have a salary greater than 70000, but exclude those who are 'Intern'?

SQL Code
SELECT * FROM employees WHERE (position = 'Manager' OR salary > 70000) AND position != 'Intern';
Q18
Single Choice

What does this query do?

SQL Code
SELECT * FROM employees WHERE NOT (department = 'HR' AND status = 'inactive');
Q19
Single Choice

Determine the correct SQL query to select orders where the order is either 'urgent' or from the 'priority' category, but exclude orders where the customer is 'anonymous':

SQL Code
SELECT * FROM orders WHERE (order_type = 'urgent' OR category = 'priority') AND customer != 'anonymous';
Q20
Single Choice

What does the following SQL query achieve?

SQL Code
SELECT * FROM products WHERE NOT (price < 50 AND (stock > 100 OR supplier = 'ABC Corp'));
Q21
Multiple Choice

Which SQL query uses the AND operator to filter employees who work in department 5 and have a salary greater than 50,000?

SQL Code
SELECT name, department_id, salary
FROM employees
WHERE department_id = 5 AND salary > 50000;
Q22
Multiple Choice

Identify the SQL query that uses the OR operator to find products that are either out of stock or priced above 100.

SQL Code
SELECT product_name, price, stock
FROM products
WHERE stock = 0 OR price > 100;
Q23
Multiple Choice

Which SQL query demonstrates the use of the NOT operator to exclude employees with a specific job title?

SQL Code
SELECT name, job_title
FROM employees
WHERE NOT job_title = 'Manager';
Q24
Multiple Choice

Determine the SQL query that uses the AND and OR operators together to filter products that are in stock and either priced above 100 or belong to category 3.

SQL Code
SELECT product_name, price, stock
FROM products
WHERE stock > 0 AND (price > 100 OR category_id = 3);
Q25
Multiple Choice

Which SQL query correctly uses the combination of AND and NOT operators to exclude employees with a salary below 50,000 and department 5?

SQL Code
SELECT name, department_id, salary
FROM employees
WHERE NOT (salary < 50000 AND department_id = 5);
Q26
Multiple Choice

Which SQL query uses the AND operator to select orders placed by customers from New York and with an order amount greater than 500?

SQL Code
SELECT order_id, customer_id, order_amount
FROM orders
WHERE customer_city = 'New York' AND order_amount > 500;
Q27
Multiple Choice

Identify the SQL query that uses the OR and NOT operators to find customers not from California or with an account balance above 1,000.

SQL Code
SELECT customer_name, state, account_balance
FROM customers
WHERE state != 'California' OR account_balance > 1000;
Q28
Multiple Choice

Which SQL query demonstrates the correct use of AND, OR, and NOT operators together to filter a complex condition?

SQL Code
SELECT product_name, price, stock
FROM products
WHERE NOT (price < 50 OR stock = 0) AND category_id = 2;
Q29
Multiple Choice

Which SQL query correctly uses the combination of AND, OR, and NOT operators to exclude certain employees based on department and salary?

SQL Code
SELECT name, department_id, salary
FROM employees
WHERE department_id != 2 AND (salary > 60000 OR NOT department_id = 4);
Q30
Multiple Choice

Which SQL query uses logical operators to find all orders placed by customers from either New York or California with an order amount greater than 500?

SQL Code
SELECT order_id, customer_id, order_amount
FROM orders
WHERE (customer_city = 'New York' OR customer_city = 'California') AND order_amount > 500;