Basic commands Flashcards
Select everything from the Customers table
SELECT * FROM Customers
Select all values from the City column in the Customer table
SELECT City FROM Customers
Select all the different values in the City column in the Customers table
SELECT DISTINCT City FROM Customers
Select the City and Address columns from the Customers table
SELECT City, Address FROM Customers
Show a count of how many distinct values there are in the City Column in the Customers table
SELECT COUNT (DISTINCT City) FROM Customers
Select all colums from the Customers table where country is equal to Mexico
SELECT * FROM Customers WHERE Country = ‘Mexico’
Select all columns from the Customer table where the UseId is 3434
SELECT * FROM Customers WHERE UserId = 3434
Select all fields from “Customers” where country is “Germany” and city is “Berlin”
SELECT * FROM Customers WHERE Country = “Germany” AND City = “Berlin”
Select all fields from “Customers” where city is “Berlin” or “München”
SELECT * FROM Customers WHERE City = “Berlin” OR City = “München”
Select all fields from “Customers” where country is NOT “Germany”
SELECT * FROM Customers WHERE NOT Country = ‘Germany’
Selects all fields from “Customers” where country is “Germany” AND city must be “Berlin” OR “München”
SELECT * FROM Customers
WHERE Country = ‘Germany’ AND (City = ‘Berlin’ OR City=”München”)
Select all customers from the “Customers” table, sorted by the “Country” column
SELECT * FROM Customers
ORDER BY Country;
Selects all customers from the “Customers” table, sorted DESCENDING by the “Country” column
SELECT * FROM Customers
ORDER BY DESC Country
Selects all customers from the “Customers” table, sorted ascending by the “Country”
SELECT * FROM Customers
ORDER BY ASC Country