SQL WHERE Clause

(0 votes, average 0 out of 5)

To extract information from a database that fulfill a specific criteria, use the SQL WHERE clause.

The SQL WHERE clause can be used with SELECT, UPDATE, and DELETE SQL statements.

Syntax:

1
<SELECT, UPDATE, OR DELETE statement> WHERE <column name> <operator> <value>

In the SELECT, UPDATE, OR DELETE statement field, enter a SELECT, UPDATE, or DELETE statement.

In the column name field, enter a valid column name.

In the operator field, use one of the following operators:

Operator Description
= Equal
!=  Not Equal. (**Does not work in all versions of SQL. <> may be needed instead**)
< Less than
> Greater than
<= Less than or equal
>= Greater than or equal
BETWEEN Between an inclusive range
LIKE Pattern Search
IN If you know the exact value you want to return for at least one of the columns.

In the value field, enter a valid value corresponding to your operator. Text or String values should be wrapped with single quotes. Integer or numeric values should NOT be enclosed in quotes.

 

Example:

Suppose there is a database with a table named birthdays, which includes the following dataset:

FirstName LastName BirthDate
Brian Johnson 1/8/1975
Nick Thomson 3/19/1965
Tyler Jones 12/17/1994

To select the row(s) with birthday(s) only for people with the first name of Nick, use the following query:

1
SELECT * FROM birthdays WHERE FirstName = 'Nick'
Partner Links:
Last Updated on Thursday, 01 July 2010 22:07  
Related Articles

» How To Take a Screenshot On Mac OS X

To take a screenshot on an Apple computer running Mac OS X, you simply use the 'Grab' application. You can open the 'Grab' application by searching for its title in the spotlight menu.Once the application is open, select 'Capture' from the menu bar and select the type of screenshot you would like to take.The four different types of screenshots are:Selection - This allows you to take a screenshot of part of the screen defined by you.Window - This allows you to take a screenshot of a single...

» How to Resize an Image in Windows XP

Many users on the web today are uploading pictures to multiple websites or e-mailing photos to friends all over the world. However, many of these people are not familiar with how to resize these photos, which in turn creates long download times for the person receiving these photos. This article will give you the basics you need to resizing photos using software already built into the Windows operation system. Follow these easy steps to resize your pictures without losing the original...

» Using Emacs to Insert or Remove Block Comments

When using some languages that don't support block comments (such as or ), it can be pretty frustrating trying to comment out large portions of code.  Fortunately emacs provides an interface which can be used to insert or remove text in multiple lines called 'rectanges'.  Rectangles are a hugely powerful tool that can be used for much more than just block comments, but for the purpose of this article we'll focus solely on how to use them for commenting out multiple lines of...