MySQL WHERE
The WHERE
clause is used to filter records. It is used to extract only those records that fulfill a specified condition.
Example with Tamil Kings
1. Using WHERE Clause
SELECT * FROM tamil_kings_auto_increment
WHERE reign_period = '985–1014 CE';
Code Explanation: This query selects records from the tamil_kings_auto_increment
table where the reign_period
is '985–1014 CE'.
Best Practices
- Use appropriate data types in conditions to avoid errors.
- Consider using indexed columns in the
WHERE
clause to improve query performance.
Key Takeaways
- The
WHERE
clause filters records based on a specified condition. - It is commonly used with
SELECT
,UPDATE
, andDELETE
statements.