WHERE Clause
The WHERE
clause is used to filter records based on specified conditions. It is often used to narrow down the result set.
Example: Using WHERE Clause
SELECT Name FROM FreedomFighters WHERE City = 'Chennai';
Output:
Returns the Name
of all freedom fighters from Chennai.
Do's and Don'ts
Do's
- Use indexed columns in the
WHERE
clause for better performance. - Combine multiple conditions with
AND
orOR
for complex filtering.
Don'ts
- Don't use
WHERE
without understanding the impact on query performance. - Don't forget to validate user input to prevent SQL injection.