ELEVATE YOUR BUSINESS WITH

Limitless customization options & Elementor compatibility let anyone create a beautiful website with Valiance.

Where in MySql

SELECT * FROM `itio_tutorial_master` WHERE `tutorial_menu`='7' AND `tutorial_submenu`='34' AND `tutorial_status`=1 LIMIT 1

Where in MySql

WHERE Clause in MySQL

The WHERE clause in MySQL is used to filter records in a SELECT, UPDATE, DELETE, or INSERT statement based on a condition.


1. Syntax

SELECT column1, column2 FROM table_nameWHERE condition;

πŸ”Ή Conditions can include:
βœ… Comparisons (=, >, <, >=, <=, !=)
βœ… Logical Operators (AND, OR, NOT)
βœ… Wildcards (LIKE)
βœ… Lists (IN)
βœ… Ranges (BETWEEN)


2. Example Table: employees

emp_idnamedepartmentsalary
1AliceIT6000
2BobHR5000
3CharlieIT5500
4DavidFinance7000


3. Using WHERE in SELECT

SELECT * FROM employees WHERE department = 'IT';

βœ… Result:

emp_idnamedepartmentsalary
1AliceIT6000
3CharlieIT5500


4. Using WHERE with Comparison Operators

SELECT * FROM employees WHERE salary > 5500;

βœ… Finds employees with salary greater than 5500.


5. Using WHERE with AND

SELECT * FROM employees WHERE department = 'IT' AND salary > 5500;

βœ… Finds employees in IT with salary greater than 5500.


6. Using WHERE with OR

SELECT * FROM employees WHERE department = 'IT' OR department = 'HR';

βœ… Finds employees in either IT or HR.


7. Using WHERE with BETWEEN

SELECT * FROM employees WHERE salary BETWEEN 5000 AND 6000;

βœ… Finds employees with salary in the range 5000-6000.


8. Using WHERE with IN

SELECT * FROM employees WHERE department IN ('IT', 'Finance');

βœ… Finds employees in IT or Finance departments.


9. Using WHERE with LIKE (Wildcard Search)

SELECT * FROM employees WHERE name LIKE 'A%';

βœ… Finds employees whose names start with "A".


10. Using WHERE in UPDATE

UPDATE employees SET salary = 6500 WHERE emp_id = 1;

βœ… Updates Alice’s salary to 6500.


11. Using WHERE in DELETE

DELETE FROM employees WHERE department = 'HR';

βœ… Removes all employees from the HR department.


Key Takeaways

βœ… The WHERE clause filters records based on conditions.
βœ… Supports comparisons, logical operators, wildcards, lists, and ranges.
βœ… Used with SELECT, UPDATE, and DELETE statements.
βœ… Always use WHERE in UPDATE and DELETE to avoid modifying all rows!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql