Try
SELECT*FROM Customers;
SELECT CustomerName, City FROM Customers;
SELECT CustomerName FROM Customers;
SELECT DISTINCT Country FROM Customers;
SELECTCOUNT(DISTINCT Country) FROM Customers;
SELECT*FROM Customers WHERE Country='Mexico';
SELECT*FROM Customers WHERE City IN ('Paris','London');
SELECT*FROM Customers WHERE City LIKE's%';
SELECT*FROM Products WHERE Price BETWEEN 50AND60;
SELECT*FROM Products WHERE Price <>18; //SQL this operator may be written as!=SELECT*FROM Products WHERE Price <=30;
SELECT*FROM Products WHERE Price >=30;
SELECT*FROM Products WHERE Price <30;
SELECT*FROM Products WHERE Price >30;
SELECT*FROM Products WHERE Price =18;SELECT*FROM Customers WHERE Country='Germany'AND (City='Berlin'OR City='München');
SELECT*FROM Customers WHERE NOT Country='Germany'AND NOT Country='USA';
SELECT*FROM Customers ORDER BY Country;
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NULL;
SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NOT NULL;
UPDATE Customers SET ContactName ='Alfred Schmidt', City='Frankfurt'WHERE CustomerID =1;
DELETEFROM Customers WHERE CustomerName='Alfreds Futterkiste';
SELECT*FROM Customers LIMIT3;
SELECT*FROM Customers WHERE Country='Germany'LIMIT3;
SELECTMIN(Price) AS SmallestPrice FROM Products;
SELECTMAX(Price) AS LargestPrice FROM Products;
SELECTCOUNT(ProductID) FROM Products;
SELECTAVG(Price) FROM Products;
SELECTSUM(Quantity) FROM OrderDetails;
SELECT*FROM Customers WHERE CustomerName LIKE'a%'; --Finds any values that start with "a"SELECT*FROM Customers WHERE CustomerName LIKE'%a'; --Finds any values that end with "a"SELECT*FROM Customers WHERE CustomerName LIKE'%or%'; --Finds any values that have "or" in any positionSELECT*FROM Customers WHERE CustomerName LIKE'_r%'; --Finds any values that have "r" in the second position--Around the Horn--Drachenblut DelikatessendSELECT*FROM Customers WHERE CustomerName LIKE'a_%'; --Finds any values that start with "a" and are at least 2 characters in length--Alfreds Futterkiste--Ana Trujillo Emparedados y heladosSELECT*FROM Customers WHERE CustomerName LIKE'a__%'; --Finds any values that start with "a" and are at least 3 characters in lengthSELECT*FROM Customers WHERE CustomerName LIKE'a%e'; --Finds any values that start with "a" and ends with "e"--Alfreds FutterkisteSELECT*FROM Customers WHERE City LIKE'_ondon'; --Selects all customers with a City starting with any character, followed by "ondon":--London SELECT*FROM Customers WHERE City LIKE'L_n_on';
SELECT*FROM Customers WHERE City LIKE'[bsp]%'; --Selects all customers with a City starting with "b", "s", or "p"--Paris --São Paulo --Portland --Seattle --Buenos AiresSELECT*FROM Customers WHERE City LIKE'[a-d]%'; --A B C DSELECT*FROM Customers WHERE City LIKE'[!bsp]%';
SELECT*FROM Customers WHERE City NOT LIKE'[bsp]%';
Copyright 2021 M. Fadli Zein