Sunday, December 4, 2011

To create a query, you can use a Wizard + Design View to further modify the query.

OR, you can just write it directly in
SQL.

http://w3schools.com/sql/default.asp

SELECT * From Books

Where Clause

SELECT Title, Year, ListPrice, Publisher
From Books
Where Publisher="Prentice Hall"

wildcards
?
*


SELECT Title, Year, ListPrice, Publisher
From Books
Where Publisher Like "Prentice?Hall"
Order By ListPrice Desc

First use the wizard to choose Table(s)
and fields. Then, add sorting and criteria
in design view.

SELECT Books.Title, Books.Year, Books.ListPrice, Books.Publisher
FROM Books
WHERE (((Books.Publisher)="Prentice Hall"))
ORDER BY Books.ListPrice DESC;


Query 2:
Select Title, Author, Year, ListPrice
From Books
Where Author Like "G*"

Begins with. G*
Ends with. *ing
Contains. *Excel*

SELECT Books.[ISBN], Books.[Title], Books.[Author], Books.[Year], Books.[ListPrice]
FROM Books
WHERE (((Books.[Author]) Like "G*"));

Query 3:
Select Title, Year, ListPrice, Publisher
From Books
Where Year >= 1995 Or ListPrice > 25
Order By Year Desc

Query 4:
Select ProductName, UnitPrice, UnitsOnOrder
From Products
Where (UnitsOnOrder=0) And (UnitPrice>=50 And UnitPrice<=100)


Select ProductName, UnitPrice, UnitsOnOrder
From Products
Where UnitsOnOrder=0 And UnitPrice Between 50 100

No comments:

Post a Comment