Here are some SQL commands to jog your memory!
Return the number of records in a table
SELECT COUNT(*) FROM table_name
Show the entire table
SELECT * FROM table_name
Show a column within the table
SELECT column_name FROM table_name
Select only the unique values within a column
SELECT DISTINCT column_name FROM table_name
Return the number of unique values from a column within a table
SELECT COUNT(DISTINCT column_name)
FROM table_name
Select all records where a certain value exists
SELECT * FROM table_name
WHERE column_name = 'value'
Select all records excluding a certain value
SELECT * FROM table_name WHERE NOT column_name = 'value'
Select all records where a certain value exists in a column and another certain value exists in another column
SELECT * FROM table_name
WHERE column1 = 'string1' AND column_2 = 'string2'
Select all records that start with a particular letter from the alphabet (in this case, the letter = a)
SELECT * FROM table_name WHERE column_name LIKE 'a%'
Select all records that end with a particular letter from the alphabet (in this case, the letter = a)
SELECT * FROM table_name WHERE column_name LIKE '%a'
Select all records with values from a column alphabetically ranging from a certain value to another certain value
SELECT * FROM table_name BETWEEN 'string1' AND 'string2'
Return records in a descending order
SELECT * FROM table_bame ORDER BY column_name DESC
Select records from a column with multiple values
SELECT * FROM Customers
WHERE column_name IN ('value1','value2');
Insert records in your table
INSERT INTO table_name VALUES ('first','second,'third','nth')
It's worth noting that the number of values you insert after the "INSERT INTO VALUES" has to correspond to the number of columns in the table you're inserting information into.
Change a record in a column to another value
UPDATE table_name SET column_name = 'new value' WHERE column_name = 'old value'
Remove records where a certain value exists
DELETE FROM table_name WHERE column_name = 'certain value'
Top comments (0)