
Rename column or table using an alias: SELECT. (The left table is the first table that appears in the statement.) Ĭombine rows from different tables but do not require the join condition: SELECT * FROM LEFT OUTER JOIN ON. FROM, Ĭombine rows from different tables: SELECT * FROM INNER JOIN ON. Get rounded average value and group by : SELECT, ROUND(AVG(), 2) FROM GROUP BY Multiple tables Get largest value in : SELECT MAX() FROM Import a database dump (more info here): mysql -u -p -h localhost = 00:00:00Ĭalculate total number of records: SELECT SUM() FROM Ĭount total number of and group by : SELECT, SUM() FROM GROUP BY Use -lock-tables=false option for locked tables (more info here). Removing table columns: ALTER TABLE DROP COLUMN ĭeleting databases: DROP DATABASE Ĭustom column output names: SELECT AS FROM Įxport a database dump (more info here): mysqldump -u -p > db_backup.sql (This also resets the incrementing counter for auto generated columns like an id column.)ĭelete all records in a table: truncate table
#REFRESH TABLES LIST IN TABLEPLUS UPDATE#
Updating records: UPDATE SET = '' WHERE = ĭeleting records: DELETE FROM WHERE = ĭelete all records from a table (without dropping the table itself): DELETE FROM Select with custom order and only limit: SELECT * FROM WHERE ORDER BY ASC LIMIT (Order: DESC, ASC) Select a range: SELECT * FROM WHERE BETWEEN and Select records starting with val and ending with ue: SELECT * FROM WHERE LIKE '' Select records starting with : SELECT * FROM WHERE LIKE '%' Select records containing : SELECT * FROM WHERE LIKE '%%'

Selecting specific records: SELECT * FROM WHERE = (Selectors:, != combine multiple selectors with AND, OR) Selecting parts of records: SELECT, FROM Ĭounting records: SELECT COUNT() FROM Ĭounting and selecting grouped records: SELECT *, (SELECT COUNT() FROM ) AS count FROM GROUP BY Selecting records: SELECT * FROM Įxplain records: EXPLAIN SELECT * FROM Inserting a record: INSERT INTO (, ) VALUES ('', '') List all indexes on a table: show index from Ĭreate new table with columns: CREATE TABLE ( VARCHAR(120), DATETIME) Īdding a column: ALTER TABLE ADD COLUMN VARCHAR(120) Īdding a column with an unique, auto-incrementing ID: ALTER TABLE ADD COLUMN int NOT NULL AUTO_INCREMENT PRIMARY KEY Access monitor: mysql -u -p (will prompt for password)Īccess database: mysql -u -p (will prompt for password)Ĭreate new database: create database ĭetermine what database is in use: select database()
