|
SQL Home
SQL TutorialIntroductionSQL Syntax SQL Select SQL Where SQL Order By SQL Top SQL Distinct SQL In SQL Alias SQL Join SQL Inner Join SQL Outer Join SQL Insert SQL Update SQL Delete SQL Functions SQL Count SQL Create SQL Create Database SQL Create Table SQL Create Index SQL Alter Table SQL Summary FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
SQL WhereIn the previous lesson, we used a SQL SELECT statement to retrieve all records from a database table. This is fine if we want to see every record, but what if we were only interested in some records? For example, what if we were only interested in individuals whose first name is "Homer"? We could use the WHERE clause. Using the WHERE clause, you can filter out only those records that satisfy a given condition. SQL WHERE Syntax
ExampleSQL WHERE Statement
Source Table
ResultGiven there are 3 people with the first name of "Homer", the results will look like this:
Multiple ConditionsYou can filter records based on more than one condition using operators. Two common operators are the AND and OR operators. AND OperatorThe AND operator filters the query to only those records that satisfy both the first condition and the second condition.
Result
OR OperatorThe OR operator filters the query to only those records that satisfy either one or the other condition.
Result
Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|