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 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...

» SQL SELECT Statement

A select statement in SQL is used to collect data from a database. The data that is pulled from the database is stored in a table-like structure, called a result-set.Syntax:1SELECT <column name(s)> FROM <table name>In the column name(s) field, you can enter single or multiple column names to select a set of columns or an asterisk (*) to select all columns from the table.In the table name field, you must enter a single valid table name.Note: SQL is not case sensitive. 'SELECT'...

» How to Setup and Secure a Wireless Network Using a Linksys Router

First thing to do is setup your router. Make sure you hook up the power cable, the modem, and all wired computers to the router. Once this has been done, verify that you can see the wireless network associated with your router. A newly created network will most likely be named 'linksys'.Open a web browser on one of the computers connected to the network. Once the web browser is open, type http://192.168.1.1 into the address bar. This will take you to the routers build-in administrator portal....