Select Title +' '+FirstName +' '+ LastName From
Employees;
... Where
Used to filter rows
Columns in the where clause do not necessarily have to appear in the Select
clause.
Expressions may include; =, > , < , >=, <=, != or <> (not equal
to),Between (for ranges), Like (for masks), In (for lists), Exists (used for embedded
subqueries to see whether any rows were returned)
Statements may be linked with And, Or , Not.
Examples
Select * From Employees Where Employees.Salary >
50000;
Select * From Employees Where FirstName =
"Tui" And (LastName = "Rangi" Or LastName = "Corich")
Select * From Employees Where LastName In
("Smith","White","Rangi");
Select * From Employees Where Lastame Like
"M%";
Finds all LastNames starting with M.
Can have %m% for all values with an m in them
Use a _ (underscore) for a single character, eg. Ha_e for Hame, Hape, etc..
Select FirstName, LastName Form Employees Where
StartDate Between #01/01/98# And #31/09/98# And EmployeeType = "Sales";
Select FirstName, LastName From Employees Where Exists
(Select* From TimeSheets Where Date > #01/01/98#);
Select CustCode, CustName From Customer Where
Customer.CustCode IN (Select Accounts.AccCode From Accounts Where CreditStatus =
"Hold");
... Group by .. Having
Goups the selected rows.
If the table does not have an index defined the query may run slowly
Having filters out unwanted groups
Examples
Select * From Timesheets Group by TsDate;
Select * From Timesheets Group by TsDate Having TsDate
Between #01/01/98# And #10/10/98#;