MySQL Tutorial – Using the WHERE clause to filter records
The WHERE clause is used to filter the data to be displayed using the SQL commands such as SELECT, UPDATE, DELETE statement.
The WHERE clause syntax:
SELECT column_name(s) FROM table_name WHERE column_name operator value;
The following operators can be used together with the WHERE clause:
[TABLE=4]
Here is our database table: (employee_record)
[TABLE=3]
Example: We will retrieve the first name and last name of employee with the position of “Programmer”. Issue the following command:
SELECT f_name,l_name FROM employee_record WHERE position=”Programmer”;
Result:
+--------+---------+ | f_name | l_name | +--------+---------+ | Piolo | Pascual | | John | Prats | +--------+---------+ 2 rows in set (0.09 sec)