C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
MySQL WHERE ClauseMySQL WHERE Clause is used with SELECT, INSERT, UPDATE and DELETE clause to filter the results. It specifies a specific position where you have to do the operation. Syntax:
WHERE conditions; conditions: It specifies the conditions that must be fulfilled for records to be selected. MySQL WHERE Clause with single conditionLet's take an example to retrieve data from a table "officers". Table structure: Execute this query: SELECT * FROM officers WHERE address = 'Mau'; Output: MySQL WHERE Clause with AND conditionIn this example, we are retrieving data from the table "officers" with AND condition. Execute the following query: SELECT * FROM officers WHERE address = 'Lucknow' AND officer_id < 5; Output: WHERE Clause with OR conditionExecute the following query: SELECT * FROM officers WHERE address = 'Lucknow' OR address = 'Mau'; Output: MySQL WHERE Clause with combination of AND & OR conditionsYou can also use the AND & OR conditions altogether with the WHERE clause. See this example: Execute the following query: SELECT * FROM officers WHERE (address = 'Mau' AND officer_name = 'Ajeet') OR (officer_id < 5); Output:
Next TopicMySQL DISTINCT Clause
|