-
-
Save gitllermopalafox/f5439f05c6be1c7bb286 to your computer and use it in GitHub Desktop.
Revisions
-
hofmannsven revised this gist
Mar 4, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,8 @@ MySQL Related tutorial: http://cd64.de/mysql-cli SQL joins infografic: http://cd64.de/sql-joins Commands ----------- -
hofmannsven revised this gist
Feb 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ MySQL =============== Related tutorial: http://cd64.de/mysql-cli -
hofmannsven revised this gist
Feb 23, 2014 . 1 changed file with 27 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,38 +11,50 @@ Access monitor: `mysql -u [username] -p` (will prompt for password) Show all databases: `show databases;` Access database: `mysql -u [username] -p [database]` (will prompt for password) Create new database: `create database [database];` Select database: `use [database];` Show all tables: `show tables;` Show table structure: `describe [table];` Create new table with columns: `CREATE TABLE [table] ([column] VARCHAR(120), [another-column] DATETIME);` Adding a column: `ALTER TABLE [table] ADD COLUMN [column] VARCHAR(120);` Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [table] ADD COLUMN [column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;` Inserting a record: `INSERT INTO [table] ([column], [column]) VALUES ('[value]', [value]');` MySQL function for datetime input: `NOW()` Selecting records: `SELECT * FROM [table];` Selecting parts of records: `SELECT [column], [another-column] FROM [table];` Counting records: `SELECT COUNT([column]) FROM [table];` Counting and selecting grouped records: `SELECT *, (SELECT COUNT([column]) FROM [table]) AS count FROM [table] GROUP BY [column];` Selecting specific records: `SELECT * FROM [table] WHERE [column] = [value];` (Selectors: `<`, `>`, `!=`) Searching records for a word: `SELECT * FROM [table] WHERE [column] LIKE '%[value]%';` Searching records for a word starting with [value]: `SELECT * FROM [table] WHERE [column] LIKE '[value]%';` Updating records: `UPDATE [table] SET [column] = '[updated-value]' WHERE [column] = [value];` Deleting records: `DELETE FROM [table] WHERE [column] = [value];` Removing table columns: `ALTER TABLE [table] DROP COLUMN [column];` Deleting tables: `DROP TABLE [table];` Deleting databases: `DROP DATABASE [database];` Custom column output names: `SELECT [column] AS [custom-column] FROM [table];` Logout: `exit` -
hofmannsven revised this gist
Feb 23, 2014 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,4 +35,14 @@ Selecting records: `SELECT * FROM [name-of-table];` Selecting parts of records: `SELECT [name-of-column], [name-of-another-column] FROM [name-of-table];` Counting records: `SELECT COUNT([name-of-column]) FROM [name-of-table];` Counting and selecting grouped records: `SELECT *, (SELECT COUNT([name-of-column]) FROM [name-of-table]) AS count FROM [name-of-table] GROUP BY [name-of-column];` Selecting specific records: `SELECT * FROM [name-of-table] WHERE [name-of-column] = [custom-input];` (Selectors: `<`, `>`, `!=`) Searching records for a word: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '%[custom-input]%';` Searching records for a word starting with [custom-input]: `SELECT * FROM [name-of-table] WHERE [name-of-column] LIKE '[custom-input]%';` Logout: `exit` -
hofmannsven revised this gist
Feb 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ Adding a column: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] VARCHA Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;` Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-column]) VALUES ('[custom-input]', [custom-input]');` MySQL function for datetime input: `NOW()` -
hofmannsven revised this gist
Feb 23, 2014 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,18 @@ Show all tables: `show tables;` Show table structure: `describe [name-of-table];` Create new table with columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);` Adding a column: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] VARCHAR(120);` Adding a column with an unique, auto-incrementing ID: `ALTER TABLE [name-of-table] ADD COLUMN [name-of-column] int NOT NULL AUTO_INCREMENT PRIMARY KEY;` Inserting a record: `INSERT INTO [name-of-table] ([name-of-column], [name-of-another-column]) VALUES ('[custom-input]', [custom-input]');` MySQL function for datetime input: `NOW()` Selecting records: `SELECT * FROM [name-of-table];` Selecting parts of records: `SELECT [name-of-column], [name-of-another-column] FROM [name-of-table];` Logout: `exit` -
hofmannsven created this gist
Feb 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ MySQL Command Line Interface =============== Related tutorial: http://cd64.de/mysql-cli Commands ----------- Access monitor: `mysql -u [username] -p` (will prompt for password) Show all databases: `show databases;` Access database: `mysql -u [username] -p [name-of-database]` (will prompt for password) Create new database: `create database [name-of-database];` Select database: `use [name-of-database];` Show all tables: `show tables;` Show table structure: `describe [name-of-table];` Create tables and columns: `CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);` Logout: `exit` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ alias mysql=/Applications/MAMP/Library/bin/mysql