FANDOM


SQL Examples

SQL Select

SELECT "column_name" FROM "table_name"

To illustrate the above example, assume that we have the following table:

Table Store_Information


store_name Sales Date
Store 1 $2500 1/8/2009
Store 2 $5000 1/9/2009
Store 1 $3000 1/10/2009
Store 4 $7000 1/10/2009

SELECT store_name FROM Store_Information

Result:

store_name

Store 1

Store 2

Store 1

Store 4


SQL Where

SELECT "column_name" FROM "table_name" WHERE "condition"

For example, to select all stores with sales above $5,000 in Table Store_Information,

Table Store_Information


store_name Sales Date
Store 1 $2500 1/8/2009
Store 2 $5000 1/9/2009
Store 1 $3000 1/10/2009
Store 4 $7000 1/10/2009

we key in,

Select store_name

From store_Information

Where Sales > 3000

Result:


store_name
Store 4


SQL Distinct

SELECT DISTINCT "column_name" FROM "table_name"

Table Store_Information



store_name Sales Date
Store 1 $2500 1/8/2009
Store 2 $5000 1/9/2009
Store 1 $3000 1/10/2009
Store 4 $7000 1/10/2009

we key in,

SELECT DISTINCT store_name FROM Store_Information

Result:



store_name
Store 1
Store 2
Store 4


References

"SQL Commands" http://www.sqlcommands.net. 19 Oct 2009 <  http://www.sqlcommands.net/sql+select>.

"SQL Commands" http://www.sqlcommands.net. 19 Oct 2009 < http://www.sqlcommands.net/sql+where>.

"SQL Commands" http://www.sqlcommands.net. 19 Oct 2009 <  http://www.sqlcommands.net/sql+distinct>.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.