SQL Command

Syntax:

SELECT fieldname …

FROM  tablename 

WHERE fieldname =/!=/<>/>/>=/</<=/IN/NOT IN/BETWEEN/NOT BETWEEN/BEGINS WITH/CONTAINS/NOT CONTAINS/ IS NULL/IS NOT NULL/LIKE /NOT/LIKE VALUE
ORDER BY fieldname <DESC>…

Explanation:

  • You can use any of the following logical operators in your Where clause to restrict the rows you retrieve.  
Logical Operators
= Equal to
!= or <> Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
in Equal to any item in a list
not in  Not equal to any item in a list
between Between two values,
greater than or equal to one and less than or equal to the other
not between Not between two values
begins with Begins with specified value
contains Contains specified value
not contains Does not contain specified value
is null Is blank
is not null Is not blank
like Like a specified pattern.
% means any series of characters.
_ means any single character.
not like Not like a specified pattern.
% means any series of characters.
_ means many single character.

 

examples :

Select City, Name, VendId
from TrnVendor
where City in ( ‘Mercer’, ‘New York’, ‘Park Ridge’)
order by City;

Select Name, City, VendId
from TrnVendor
where Name begins with ‘Co’
order by Name;

Select Name, City, VendId
from TrnVendor
where City like ‘%do’
order by City;

Select VendId, Name, CurrBal [ZZ,ZZZ.99]
from TrnVendor
where CurrBal between 500 and 1000
order by CurrBal;

from : http://www.baycongroup.com/sql_command_reference.htm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s