Starting Access work
- Databases
- Sources
- Files
- into SQL
- Structured Query Language
- Tools for retrieving data
- SELECT
- FROM
- WHERE
Basic Pets SQL Query
SELECT Pets.Name, Pets.[Date of Birth]
FROM Pets
WHERE (((Pets.Kind)="cat"));
There are reserved words in SQL ie SELECT
, FROM
, and WHERE
*
means all colums
SELECT *
FROM Pets;
SELECT name, kind
FROM Pets;
SELECT *
FROM Pets
WHERE kind='dog';
gives back all pet entries with dog
SELECT *
FROM Pets
WHERE kind='dog' OR
kind='cat';
SELECT *
FROM Pets
WHERE name='khan';
The customer number and company name for all customers that are the owner or sales manager of their business.
SELECT CustomerID, CompanyName
FROM Customers
WHERE ContactTitle="Owner" OR ContactTitle="Sales Manager"
Query2 The product name, category name, and units in stock for all products that cost at least 20.00 and have a reorder level of 0.
SELECT Products.ProductName, Categories.CategoryName, Products.UnitsInStock
FROM Products, Categories
WHERE Products.UnitsInStock >= 20 AND Products.ReorderLevel=0 AND Categories.CategoryID=Products.CategoryID;
Query3 The names of all customers who ordered a product supplied by Leka Trading or Exotic Liquids.
SELECT Customers.CompanyName
FROM Customers, Suppliers
WHERE (((Suppliers.CompanyName)="Leka Trading" Or (Suppliers.CompanyName)="Exotic Liquids"));
*Incomplete
Give me the count of all records
SELECT count(*)
FROM ORDERS;