MySQL Database Quiz Questions

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

In MySQL, the 'AND' operator is used to combine multiple conditions and returns true only if all conditions are true.

Q2
True / False

The 'OR' operator in MySQL returns true if at least one of the combined conditions is true.

Q3
True / False

In MySQL, the expression 1 AND 0 evaluates to true.

Q4
True / False

In MySQL, the 'AND' operator has higher precedence than the 'OR' operator.

Q5
True / False

The query SELECT * FROM employees WHERE age > 30 AND age < 50 OR salary > 50000; will return employees who are either aged between 30 and 50 or have a salary greater than 50000.

Q6
True / False

The query SELECT * FROM products WHERE price < 100 AND category = 'Electronics' OR stock > 50; will return all electronics priced under 100, as well as any product with stock greater than 50.

Q7
True / False

In MySQL, you can use both 'AND' and 'OR' operators within the same WHERE clause to create complex conditions.

Q8
True / False

The expression (condition1 OR condition2) AND condition3 is equivalent to condition1 OR (condition2 AND condition3) in MySQL.

Q9
True / False

The query SELECT * FROM orders WHERE (customer_id = 1 OR customer_id = 2) AND (status = 'shipped' OR status = 'pending'); will return orders for customers 1 or 2 that are either shipped or pending.

Q10
True / False

In MySQL, using 'AND' and 'OR' operators within a single query can impact query performance, especially when dealing with large datasets.

Q11
Single Choice

What will be the result of the following MySQL query?

SQL Code
SELECT * FROM employees WHERE department = 'HR' AND salary > 50000;
Q12
Single Choice

What does the following SQL statement return?

SQL Code
SELECT name FROM students WHERE age < 18 OR grade = 'A';
Q13
Single Choice

In the following query, which rows will be selected?

SQL Code
SELECT * FROM orders WHERE order_date > '2024-01-01' AND customer_id = 1001;
Q14
Single Choice

What does the following MySQL query return?

SQL Code
SELECT product_name FROM products WHERE stock < 50 AND (price > 100 OR category = 'Electronics');
Q15
Single Choice

Evaluate the following query. Which of the following statements is correct?

SQL Code
SELECT id FROM users WHERE (city = 'New York' AND age > 25) OR (city = 'Los Angeles' AND age < 30);
Q16
Single Choice

Given the following table sales:

SQL Code
+-----------+------------+--------+--------+
| product | sale_date | region | amount |
+-----------+------------+--------+--------+
| A | 2024-07-01 | East | 1000 |
| B | 2024-07-02 | West | 2000 |
| C | 2024-07-03 | East | 1500 |
| D | 2024-07-04 | West | 3000 |
+-----------+------------+--------+--------+
What will be the result of this query?
SELECT product FROM sales WHERE region = 'East' OR amount > 2000;
Q17
Single Choice

What does the following SQL statement return?

SQL Code
SELECT customer_id FROM transactions WHERE (status = 'completed' OR status = 'shipped') AND total > 500;
Q18
Single Choice

Consider the following SQL statement. Which records will be selected?

SQL Code
SELECT order_id FROM orders WHERE (priority = 'high' AND delivery_date < '2024-08-01') OR (priority = 'low' AND delivery_date > '2024-08-05');
Q19
Single Choice

Analyze the following SQL query. Which orders will be selected?

SQL Code
SELECT * FROM orders WHERE (total_amount > 1000 AND customer_id IN (SELECT customer_id FROM customers WHERE vip_status = 'yes')) OR (order_date BETWEEN '2024-01-01' AND '2024-06-30');
Q20
Single Choice

For the following query, which employees will be selected?

SQL Code
SELECT employee_id FROM employees WHERE (job_title = 'Manager' OR department = 'Finance') AND (hire_date > '2020-01-01' AND salary > 75000);
Q21
Multiple Choice

Which query correctly retrieves records from the 'employees' table where 'department_id' is 1 AND 'salary' is greater than 50000?

SQL Code
SELECT *
FROM employees
WHERE department_id = 1
AND salary > 50000;
Q22
Multiple Choice

Identify the correct SQL query that retrieves records from the 'orders' table where 'order_date' is '2023-01-01' OR 'status' is 'Pending'.

SQL Code
SELECT *
FROM orders
WHERE order_date = '2023-01-01'
OR status = 'Pending';
Q23
Multiple Choice

Which query correctly selects records from the 'products' table where 'price' is less than 100 AND 'stock' is greater than 10?

SQL Code
SELECT *
FROM products
WHERE price < 100
AND stock > 10;
Q24
Multiple Choice

Determine the correct SQL query that retrieves records from the 'customers' table where 'country' is 'USA' OR 'state' is 'California'.

SQL Code
SELECT *
FROM customers
WHERE country = 'USA'
OR state = 'California';
Q25
Multiple Choice

Which SQL query retrieves records from the 'inventory' table where 'category' is 'Electronics' AND 'quantity' is less than 50?

SQL Code
SELECT *
FROM inventory
WHERE category = 'Electronics'
AND quantity < 50;
Q26
Multiple Choice

Which query correctly retrieves records from the 'employees' table where 'job_title' is 'Manager' OR 'hire_date' is before '2020-01-01'?

SQL Code
SELECT *
FROM employees
WHERE job_title = 'Manager'
OR hire_date < '2020-01-01';
Q27
Multiple Choice

Determine the correct SQL query that selects records from the 'sales' table where 'region' is 'North' AND 'sales_amount' is greater than 1000.

SQL Code
SELECT *
FROM sales
WHERE region = 'North'
AND sales_amount > 1000;
Q28
Multiple Choice

Which SQL query retrieves records from the 'projects' table where 'status' is 'Active' AND 'budget' is less than 50000?

SQL Code
SELECT *
FROM projects
WHERE status = 'Active'
AND budget < 50000;
Q29
Multiple Choice

Identify the correct query that retrieves records from the 'clients' table where 'industry' is 'Finance' OR 'revenue' is greater than 1000000.

SQL Code
SELECT *
FROM clients
WHERE industry = 'Finance'
OR revenue > 1000000;
Q30
Multiple Choice

Which SQL query correctly retrieves records from the 'transactions' table where 'payment_method' is 'Credit Card' AND 'amount' is less than 500?

SQL Code
SELECT *
FROM transactions
WHERE payment_method = 'Credit Card'
AND amount < 500;