The MySQL WHERE clause is used to filter rows based on a particular condition. The WHERE clause is used with SELECT, INSERT, UPDATE and DELETE statements. If you use the SELECT statement to fetch the data from tables without the WHERE clause, you will get all rows in the tables. MySQL allows you to use operator with Where clause.
To fetch the data based on specific condition, use the following syntax:
Parameters:
conditions: To specify the condition that must be fulfilled for records to be selected.
Note:
In the above example, we have fetched record from "tblCustomerLoan" table with cellNo "2888888980".
You can use MySQL Command Line Client to fetch record from "tblCustomerLoan" table based on specific condition. It will look like this:
Note:
In the above example, we have fetch records from "tblCustomerLoan" table with cellNo "2888888980" AND aadharNo equal to "123456789012".
You can use MySQL Command Line Client to fetch record from "tblCustomerLoan" table based on AND condition. It will look like this:
Note:
In the above example, we have fetch records from "tblCustomerLoan" table with cellNo "2888888980" OR aadharNo equal to "123456789012".
You can use MySQL Command Line Client to fetch record from "tblCustomerLoan" table based on OR condition. It will look like this:
Note:
In the above example, we have fetch records from "tblCustomerLoan" table with cellNo "2888888980" OR aadharNo equal to "123456789012".
You can use MySQL Command Line Client to fetch record from "tblCustomerLoan" table based on AND & OR condition. It will look like this:
Some more useful operators that you can use with WHERE clause to form a complex conditions such as:
The WHERE clause is used with SELECT, INSERT, UPDATE and DELETE statements as well.