Create a gist now

Instantly share code, notes, and snippets.

Embed
My simply MySQL Command Line Cheatsheet

MySQL

Getting started:

Related tutorials:

Tools:

Commands

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];

Determine what database is in use: select database();

Show all tables: show tables;

Show table structure: describe [table];

List all indexes on a table: show index from [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];

Explain records: EXPLAIN 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: <, >, !=; combine multiple selectors with AND, OR)

Select records containing [value]: SELECT * FROM [table] WHERE [column] LIKE '%[value]%';

Select records starting with [value]: SELECT * FROM [table] WHERE [column] LIKE '[value]%';

Select records starting with val and ending with ue: SELECT * FROM [table] WHERE [column] LIKE '[val_ue]';

Select a range: SELECT * FROM [table] WHERE [column] BETWEEN [value1] and [value2];

Select with custom order and only limit: SELECT * FROM [table] WHERE [column] ORDER BY [column] ASC LIMIT [value]; (Order: DESC, ASC)

Updating records: UPDATE [table] SET [column] = '[updated-value]' WHERE [column] = [value];

Deleting records: DELETE FROM [table] WHERE [column] = [value];

Delete all records from a table (without dropping the table itself): DELETE FROM [table]; (This also resets the incrementing counter for auto generated columns like an id column.)

Delete all records in a table: truncate table [table];

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];

Export a database dump (more info here): mysqldump -u [username] -p [database] > db_backup.sql

Use --lock-tables=false option for locked tables (more info here).

Import a database dump (more info here): mysql -u [username] -p -h localhost [database] < db_backup.sql

Logout: exit;

Aggregate functions

Select but without duplicates: SELECT distinct name, email, acception FROM owners WHERE acception = 1 AND date >= 2015-01-01 00:00:00

Calculate total number of records: SELECT SUM([column]) FROM [table];

Count total number of [column] and group by [category-column]: SELECT [category-column], SUM([column]) FROM [table] GROUP BY [category-column];

Get largest value in [column]: SELECT MAX([column]) FROM [table];

Get smallest value: SELECT MIN([column]) FROM [table];

Get average value: SELECT AVG([column]) FROM [table];

Get rounded average value and group by [category-column]: SELECT [category-column], ROUND(AVG([column]), 2) FROM [table] GROUP BY [category-column];

Multiple tables

Select from multiple tables: SELECT [table1].[column], [table1].[another-column], [table2].[column] FROM [table1], [table2];

Combine rows from different tables: SELECT * FROM [table1] INNER JOIN [table2] ON [table1].[column] = [table2].[column];

Combine rows from different tables but do not require the join condition: SELECT * FROM [table1] LEFT OUTER JOIN [table2] ON [table1].[column] = [table2].[column]; (The left table is the first table that appears in the statement.)

Rename column or table using an alias: SELECT [table1].[column] AS '[value]', [table2].[column] AS '[value]' FROM [table1], [table2];

Users functions

List all users: SELECT User,Host FROM mysql.user;

Create new user: CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Grant ALL access to user for * tables: GRANT ALL ON database.* TO 'user'@'localhost';

Find out the IP Address of the Mysql Host

SHOW VARIABLES WHERE Variable_name = 'hostname'; (source)

alias mysql=/Applications/MAMP/Library/bin/mysql
[mysqld]
max_allowed_packet=64M
@franz-josef-kaiser

This comment has been minimized.

Show comment
Hide comment
@franz-josef-kaiser

franz-josef-kaiser Nov 8, 2014

Delete all records from a table (without dropping the table itself): delete from [tablename]. This also resets the incrementing counter for auto generated columns like an id column.

Delete all records from a table (without dropping the table itself): delete from [tablename]. This also resets the incrementing counter for auto generated columns like an id column.

@hofmannsven

This comment has been minimized.

Show comment
Hide comment
@hofmannsven

hofmannsven Nov 8, 2014

Thanks! I've added it above and also shared it on WPSE :)

Owner

hofmannsven commented Nov 8, 2014

Thanks! I've added it above and also shared it on WPSE :)

@anjanb

This comment has been minimized.

Show comment
Hide comment
@anjanb

anjanb Jul 24, 2015

Grunt ALL
Should that not be "GRANT ALL" ?

anjanb commented Jul 24, 2015

Grunt ALL
Should that not be "GRANT ALL" ?

@hofmannsven

This comment has been minimized.

Show comment
Hide comment
@hofmannsven

hofmannsven Aug 11, 2015

@anjanb Thx for the hint! Fixed it.

Owner

hofmannsven commented Aug 11, 2015

@anjanb Thx for the hint! Fixed it.

@matthewhartstonge

This comment has been minimized.

Show comment
Hide comment
@matthewhartstonge

matthewhartstonge Dec 6, 2015

For scripting:
Comments: /* This is a comment */

Gets me every time between all the languages haha

For scripting:
Comments: /* This is a comment */

Gets me every time between all the languages haha

@mhenes

This comment has been minimized.

Show comment
Hide comment
@mhenes

mhenes Jan 12, 2016

For importing or loading data from local csv file into MySQL db (remove LOCAL if not local):
LOAD DATA LOCAL INFILE '/file/path/inputdata.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r' IGNORE 1 LINES;

For exporting MySQL table from MySQL prompt to csv file (will require root permission most likely) :
SELECT column_name FROM table_name INTO OUTFILE '/tmp/outfile.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

For exporting MySQL table from Terminal or Apple Command line to csv file:
mysql --host=localhost --user=user_name -p table_name -e "select column_name from table_name INTO OUTFILE '/tmp/outfile.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';"

mhenes commented Jan 12, 2016

For importing or loading data from local csv file into MySQL db (remove LOCAL if not local):
LOAD DATA LOCAL INFILE '/file/path/inputdata.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r' IGNORE 1 LINES;

For exporting MySQL table from MySQL prompt to csv file (will require root permission most likely) :
SELECT column_name FROM table_name INTO OUTFILE '/tmp/outfile.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

For exporting MySQL table from Terminal or Apple Command line to csv file:
mysql --host=localhost --user=user_name -p table_name -e "select column_name from table_name INTO OUTFILE '/tmp/outfile.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';"

@junrillg

This comment has been minimized.

Show comment
Hide comment
@junrillg

junrillg Feb 2, 2016

Find out the IP Address of the Mysql Host

SHOW VARIABLES WHERE Variable_name = 'hostname'

resource

junrillg commented Feb 2, 2016

Find out the IP Address of the Mysql Host

SHOW VARIABLES WHERE Variable_name = 'hostname'

resource

@hofmannsven

This comment has been minimized.

Show comment
Hide comment
@hofmannsven

hofmannsven Feb 5, 2016

👍

Owner

hofmannsven commented Feb 5, 2016

👍

@maxwsd

This comment has been minimized.

Show comment
Hide comment
@maxwsd

maxwsd May 12, 2016

when I create that alias you suggested for MAMP and "show databases" all of my databases are not visible, only information_schema database. Any idea? Thank you!

maxwsd commented May 12, 2016

when I create that alias you suggested for MAMP and "show databases" all of my databases are not visible, only information_schema database. Any idea? Thank you!

@hofmannsven

This comment has been minimized.

Show comment
Hide comment
@hofmannsven

hofmannsven May 23, 2016

@maxwsd Did you source your config file after the change like source .bash_profile?

Owner

hofmannsven commented May 23, 2016

@maxwsd Did you source your config file after the change like source .bash_profile?

@vungocthien

This comment has been minimized.

Show comment
Hide comment
@vungocthien

vungocthien Jun 8, 2016

Great! Thanks so much!

Great! Thanks so much!

@nweak38

This comment has been minimized.

Show comment
Hide comment
@nweak38

nweak38 Jun 11, 2016

Thanks bro! very helpful for me as a beginner.

👍

nweak38 commented Jun 11, 2016

Thanks bro! very helpful for me as a beginner.

👍

@asinode

This comment has been minimized.

Show comment
Hide comment
@asinode

asinode Jun 13, 2016

Thank you. Very helpful.

asinode commented Jun 13, 2016

Thank you. Very helpful.

@Soufraz

This comment has been minimized.

Show comment
Hide comment
@Soufraz

Soufraz Jul 18, 2016

select database();
To determine what database is in use

truncate table [table-name];
To delete all records in a table

Soufraz commented Jul 18, 2016

select database();
To determine what database is in use

truncate table [table-name];
To delete all records in a table

@tomc12n

This comment has been minimized.

Show comment
Hide comment
@tomc12n

tomc12n Jul 26, 2016

To list indexes on a table, SHOW INDEX FROM tbl_name.

tomc12n commented Jul 26, 2016

To list indexes on a table, SHOW INDEX FROM tbl_name.

@hofmannsven

This comment has been minimized.

Show comment
Hide comment
@hofmannsven

hofmannsven Jul 28, 2016

Thank you very much for your addition 👍

Owner

hofmannsven commented Jul 28, 2016

Thank you very much for your addition 👍

@ryanjstout

This comment has been minimized.

Show comment
Hide comment
@ryanjstout

ryanjstout Aug 11, 2016

Might be helpful to add -h note at top on initial connection (for those connecting to remote DB like AWS RDS):

mysql -h endpoint.amazonaws.com -P 3306 -u username -p

Might be helpful to add -h note at top on initial connection (for those connecting to remote DB like AWS RDS):

mysql -h endpoint.amazonaws.com -P 3306 -u username -p

@Soufraz

This comment has been minimized.

Show comment
Hide comment
@Soufraz

Soufraz Aug 24, 2016

mysqldump -u [user] -p[password] --all-databases > all_databases.sql
Backup all databases

Soufraz commented Aug 24, 2016

mysqldump -u [user] -p[password] --all-databases > all_databases.sql
Backup all databases

@sirfrank

This comment has been minimized.

Show comment
Hide comment
@sirfrank

sirfrank Sep 7, 2016

TRUNCATE TABLE tablename; is the one to reset the auto-increment value,
delete
not the DELETE FROM tablename;

sirfrank commented Sep 7, 2016

TRUNCATE TABLE tablename; is the one to reset the auto-increment value,
delete
not the DELETE FROM tablename;

@sirfrank

This comment has been minimized.

Show comment
Hide comment
@sirfrank

sirfrank Sep 7, 2016

add unique key to column:
ALTER IGNORE TABLE mytbl ADD UNIQUE (columnName);

sirfrank commented Sep 7, 2016

add unique key to column:
ALTER IGNORE TABLE mytbl ADD UNIQUE (columnName);

@sirfrank

This comment has been minimized.

Show comment
Hide comment
@sirfrank

sirfrank Sep 13, 2016

rename table

RENAME TABLE oldTablename TO nemTablename;

sirfrank commented Sep 13, 2016

rename table

RENAME TABLE oldTablename TO nemTablename;

@mansurabbas

This comment has been minimized.

Show comment
Hide comment
@mansurabbas

mansurabbas Oct 15, 2016

I can't get to mysql monitor

I can't get to mysql monitor

@Acrunam

This comment has been minimized.

Show comment
Hide comment
@Acrunam

Acrunam Nov 1, 2016

This is REALLY useful. Thanks!

Acrunam commented Nov 1, 2016

This is REALLY useful. Thanks!

@denohk

This comment has been minimized.

Show comment
Hide comment
@denohk

denohk Nov 8, 2016

All of these stuff are the skin of knowledge of DB. But they are helpful. could you provide the DB background resource also? thx.

denohk commented Nov 8, 2016

All of these stuff are the skin of knowledge of DB. But they are helpful. could you provide the DB background resource also? thx.

@vishwakarma09

This comment has been minimized.

Show comment
Hide comment
@vishwakarma09

vishwakarma09 Nov 9, 2016

create a table from some other table

  1. with data
    create tabe <targettable> as select * from <sourcedb>.<sourcetable>
  2. without data
    create table <targettable> like <sourcedb>.<sourcetable>

create a table from some other table

  1. with data
    create tabe <targettable> as select * from <sourcedb>.<sourcetable>
  2. without data
    create table <targettable> like <sourcedb>.<sourcetable>
@pascalandy

This comment has been minimized.

Show comment
Hide comment
@pascalandy

pascalandy Nov 14, 2016

Hi folks!

Trying to create a a new DB and a new USER with variables (via a bash script). These classic commands are working:

CREATE DATABASE usermama;
CREATE USER 'usermama'@'%' IDENTIFIED BY 'fancypass0ZGViYgn7rRHh6ny';
GRANT ALL PRIVILEGES ON usermama.* TO 'usermama'@'%';
FLUSH PRIVILEGES;
SHOW DATABASES;

All good! Now same concept with variables:

SET @ENV_ID := 'usermama';
SET @ENV_PASS := 'fancypass0ZGViYgn7rRHh6ny';
CREATE DATABASE '@ENV_ID';
CREATE USER '@ENV_ID'@'%' IDENTIFIED BY '@ENV_PASS';
GRANT ALL PRIVILEGES ON '@ENV_ID.*' TO '@ENV_ID'@'%';
FLUSH PRIVILEGES;
SHOW DATABASES;

I getting this error :(

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@ENV_ID' at line 1

Will really appreciate your help!
twitter.com/_pascalandy

pascalandy commented Nov 14, 2016

Hi folks!

Trying to create a a new DB and a new USER with variables (via a bash script). These classic commands are working:

CREATE DATABASE usermama;
CREATE USER 'usermama'@'%' IDENTIFIED BY 'fancypass0ZGViYgn7rRHh6ny';
GRANT ALL PRIVILEGES ON usermama.* TO 'usermama'@'%';
FLUSH PRIVILEGES;
SHOW DATABASES;

All good! Now same concept with variables:

SET @ENV_ID := 'usermama';
SET @ENV_PASS := 'fancypass0ZGViYgn7rRHh6ny';
CREATE DATABASE '@ENV_ID';
CREATE USER '@ENV_ID'@'%' IDENTIFIED BY '@ENV_PASS';
GRANT ALL PRIVILEGES ON '@ENV_ID.*' TO '@ENV_ID'@'%';
FLUSH PRIVILEGES;
SHOW DATABASES;

I getting this error :(

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@ENV_ID' at line 1

Will really appreciate your help!
twitter.com/_pascalandy

@pleycpl

This comment has been minimized.

Show comment
Hide comment
@pleycpl

pleycpl Mar 17, 2017

Thanks, this is nice document. Maybe we can show better (https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet).
Like this.(```sql)

CREATE TABLE [table] (
   [column] VARCHAR(120),
   [another-column] DATETIME
);

I saw this gist now.

pleycpl commented Mar 17, 2017

Thanks, this is nice document. Maybe we can show better (https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet).
Like this.(```sql)

CREATE TABLE [table] (
   [column] VARCHAR(120),
   [another-column] DATETIME
);

I saw this gist now.

@matthewhartstonge

This comment has been minimized.

Show comment
Hide comment
@matthewhartstonge

matthewhartstonge Mar 29, 2017

One line to Create user and Grant ALL access to user for * tables: GRANT ALL PRIVILEGES ON database_name.* To 'user'@'localhost' IDENTIFIED BY 'password';

matthewhartstonge commented Mar 29, 2017

One line to Create user and Grant ALL access to user for * tables: GRANT ALL PRIVILEGES ON database_name.* To 'user'@'localhost' IDENTIFIED BY 'password';

@KNOWV

This comment has been minimized.

Show comment
Hide comment
@KNOWV

KNOWV Apr 6, 2017

mysql> select * from CALLOG limit 3;
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+
oid vendor startdate duration agent status disposition
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+
1 TCR 2017-01-04 09:22:39 0 NOTANDOG 00-NAN
2 TCR 2017-01-18 14:06:44 1 NOXOLOD1 01-NPC
3 TCR 2017-01-04 09:22:32 5 NOTANDOG 01-NPC
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+

Hi guy,

Need your help here

I want to do distinct count on "disposition" where start date is >='2017-01-01 00:00:00' , <'2017-02-01 00:00:00';

Thank you in advance

Regards,

KNOWV commented Apr 6, 2017

mysql> select * from CALLOG limit 3;
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+
oid vendor startdate duration agent status disposition
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+
1 TCR 2017-01-04 09:22:39 0 NOTANDOG 00-NAN
2 TCR 2017-01-18 14:06:44 1 NOXOLOD1 01-NPC
3 TCR 2017-01-04 09:22:32 5 NOTANDOG 01-NPC
+-----+--------+-------+-------+------------------+---------------+------------+---------------------+----------+----------+--------+-------------+

Hi guy,

Need your help here

I want to do distinct count on "disposition" where start date is >='2017-01-01 00:00:00' , <'2017-02-01 00:00:00';

Thank you in advance

Regards,

@saurabh-rao

This comment has been minimized.

Show comment
Hide comment
@saurabh-rao

saurabh-rao May 27, 2017

Another command that we can add is the show table status command. Gives more information about the table ( ex : create_time , rows etc ) .
Format :
SHOW TABLE STATUS;
-- this shows the status for all the tables in the database
SHOW TABLE STATUS LIKE '[TABLE_NAME}';
-- this shows the status for a particular table in the database. `

`Hope this is useful !

saurabh-rao commented May 27, 2017

Another command that we can add is the show table status command. Gives more information about the table ( ex : create_time , rows etc ) .
Format :
SHOW TABLE STATUS;
-- this shows the status for all the tables in the database
SHOW TABLE STATUS LIKE '[TABLE_NAME}';
-- this shows the status for a particular table in the database. `

`Hope this is useful !

@rajn3866

This comment has been minimized.

Show comment
Hide comment
@rajn3866

rajn3866 Oct 7, 2017

How to check "pause after each screenful of information" in MYSQL like /p in command
or
check tables page wise in mysql

rajn3866 commented Oct 7, 2017

How to check "pause after each screenful of information" in MYSQL like /p in command
or
check tables page wise in mysql

@sebastian-blum

This comment has been minimized.

Show comment
Hide comment
@sebastian-blum

sebastian-blum Dec 14, 2017

For adding the ID column: maybe add "FIRST" attribute to make it the 1st column in the table.

ALTER TABLE [table] ADD COLUMN [column] int NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

sebastian-blum commented Dec 14, 2017

For adding the ID column: maybe add "FIRST" attribute to make it the 1st column in the table.

ALTER TABLE [table] ADD COLUMN [column] int NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

@whitni

This comment has been minimized.

Show comment
Hide comment
@whitni

whitni Dec 20, 2017

I'd "updated" the update command.
UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]');

Example: UPDATE names SET first = replace(first, 'Mike', 'Michael');
This will update all records in the names table, first field that have Mike and change them to Michael.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '%[string]%'

This allows you to only affect rows with a certain string anywhere in them.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '%[string]'

This allows you to only affect rows that end with a certain string.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '[string]%'

This allows you to only affect rows that start with a certain string.

whitni commented Dec 20, 2017

I'd "updated" the update command.
UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]');

Example: UPDATE names SET first = replace(first, 'Mike', 'Michael');
This will update all records in the names table, first field that have Mike and change them to Michael.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '%[string]%'

This allows you to only affect rows with a certain string anywhere in them.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '%[string]'

This allows you to only affect rows that end with a certain string.

UPDATE [table] SET [column] = replace([column], '[old string]', '[new string]'); WHERE [column] like '[string]%'

This allows you to only affect rows that start with a certain string.

@strarsis

This comment has been minimized.

Show comment
Hide comment
@strarsis

strarsis Jan 18, 2018

IMHO examples are missing for:

  • Checking a database or all databases
  • Repairing a database or all databases

IMHO examples are missing for:

  • Checking a database or all databases
  • Repairing a database or all databases
@fbownz

This comment has been minimized.

Show comment
Hide comment
@fbownz

fbownz Feb 21, 2018

To repair a table on Mysql
If your MySQL process is running, stop it. On Debian:

sudo service mysql stop
Go to your data folder. On Debian:

cd /var/lib/mysql/$DATABASE_NAME
Try running:

myisamchk -r $TABLE_NAME
Or if you have more files with the same table name.
myisamchk -r $TABLE_NAME.*

If that doesn't work, you can try:

myisamchk -r -v -f $TABLE_NAME.*

You can start your MySQL server again. On Debian:

sudo service mysql start

I had to repair one of my tables recently.
Hope this helps

fbownz commented Feb 21, 2018

To repair a table on Mysql
If your MySQL process is running, stop it. On Debian:

sudo service mysql stop
Go to your data folder. On Debian:

cd /var/lib/mysql/$DATABASE_NAME
Try running:

myisamchk -r $TABLE_NAME
Or if you have more files with the same table name.
myisamchk -r $TABLE_NAME.*

If that doesn't work, you can try:

myisamchk -r -v -f $TABLE_NAME.*

You can start your MySQL server again. On Debian:

sudo service mysql start

I had to repair one of my tables recently.
Hope this helps

@nareshnaani

This comment has been minimized.

Show comment
Hide comment
@nareshnaani

nareshnaani Apr 2, 2018

Thanks.
it's very useful.

Thanks.
it's very useful.

@xxandra

This comment has been minimized.

Show comment
Hide comment
@xxandra

xxandra Apr 9, 2018

nice... thanks!

xxandra commented Apr 9, 2018

nice... thanks!

@baikaresandeep

This comment has been minimized.

Show comment
Hide comment
@baikaresandeep

baikaresandeep Apr 13, 2018

Really Nice.
Very helpful for me!

Thanks.

baikaresandeep commented Apr 13, 2018

Really Nice.
Very helpful for me!

Thanks.

@kridley73

This comment has been minimized.

Show comment
Hide comment
@kridley73

kridley73 Apr 17, 2018

Faced with a relational database that is completely new to you, what CLI statements might you run to stealthily learn about what it contains?

Faced with a relational database that is completely new to you, what CLI statements might you run to stealthily learn about what it contains?

@Edser9

This comment has been minimized.

Show comment
Hide comment
@Edser9

Edser9 Apr 27, 2018

View variables:
show variables like 'variable_name';
show global variables like 'variable_name';

Set variables:
set variable_name=0000;
set global variable_name=0000;

Edser9 commented Apr 27, 2018

View variables:
show variables like 'variable_name';
show global variables like 'variable_name';

Set variables:
set variable_name=0000;
set global variable_name=0000;

@AzimTirmizi

This comment has been minimized.

Show comment
Hide comment
@AzimTirmizi

AzimTirmizi May 3, 2018

[I am new to Mysql, I am usingthe following command]
SELECT * StudentDetails WHERE firstname LIKE '%miz%;
[Gives me] '>
what is the meaning of this and why am I getting this '>. [I beleive my syntax is correct so why do I get this '> ?]
[Please advice?]

[I am new to Mysql, I am usingthe following command]
SELECT * StudentDetails WHERE firstname LIKE '%miz%;
[Gives me] '>
what is the meaning of this and why am I getting this '>. [I beleive my syntax is correct so why do I get this '> ?]
[Please advice?]

@Neil-Mitchell

This comment has been minimized.

Show comment
Hide comment
@Neil-Mitchell

Neil-Mitchell May 4, 2018

this is an awesome cheat sheet. Maybe include View commands?

http://www.mysqltutorial.org/mysql-views-tutorial.aspx

this is an awesome cheat sheet. Maybe include View commands?

http://www.mysqltutorial.org/mysql-views-tutorial.aspx

@abaar

This comment has been minimized.

Show comment
Hide comment
@abaar

abaar May 7, 2018

how to show all view tables?

abaar commented May 7, 2018

how to show all view tables?

@sergiihoroshko

This comment has been minimized.

Show comment
Hide comment
@sergiihoroshko

sergiihoroshko May 14, 2018

README.md has 404 on codecademy link. Now SQL for codecademy Thanks you

sergiihoroshko commented May 14, 2018

README.md has 404 on codecademy link. Now SQL for codecademy Thanks you

@OlukaDenis

This comment has been minimized.

Show comment
Hide comment
@OlukaDenis

OlukaDenis May 16, 2018

How can I create two alias names for more than one column?
I tried this;
SELECT CustomerName AS Customer, ContactName AS [Contact Person]
FROM Customers;
and it was giving me an error.
what is the best way to manipulate that command?

How can I create two alias names for more than one column?
I tried this;
SELECT CustomerName AS Customer, ContactName AS [Contact Person]
FROM Customers;
and it was giving me an error.
what is the best way to manipulate that command?

@molekulerbiyolog

This comment has been minimized.

Show comment
Hide comment
@molekulerbiyolog

molekulerbiyolog May 28, 2018

Thanks a lot!!!!

Thanks a lot!!!!

@bradw2k

This comment has been minimized.

Show comment
Hide comment
@bradw2k

bradw2k May 30, 2018

Very good! Need to add -h to the first line, for selecting the host machine.

bradw2k commented May 30, 2018

Very good! Need to add -h to the first line, for selecting the host machine.

@dash025

This comment has been minimized.

Show comment
Hide comment
@dash025

dash025 Jun 11, 2018

Thanks, very helpful!

dash025 commented Jun 11, 2018

Thanks, very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment