Where clause in Mysql

The WHERE clause in MySQL is used to specify a condition that filters the rows returned by a query. It allows you to retrieve only the rows that satisfy the specified condition. Here's an example of using the WHERE clause:

Let's consider a table called customers with the following structure:

Syntax:
                
    CREATE TABLE customers (
      id INT PRIMARY KEY,
      name VARCHAR(50),
      age INT,
      city VARCHAR(50)
    );
                
            

And suppose we want to retrieve all the customers from the city of "New York" who are above 30 years old. We can use the WHERE clause to specify the condition:

Syntax:
                
    SELECT * FROM customers WHERE city = 'New York' AND age > 30;
                
            

In the above example, the WHERE clause filters the rows based on two conditions: city = 'New York' and age > 30. Only the rows that meet both conditions will be returned in the result set.

You can use various operators within the WHERE clause, such as =, <>, >, <, >=, <=, LIKE, IN, BETWEEN etc., to define your conditions.

Remember to replace customers with the actual name of your table, and adapt the condition in the WHERE clause to suit your specific requirements.

Note: When using string values in the WHERE clause, it's important to enclose them in single quotes (''). Numeric values do not require quotes.