Mysql query commands
display the MySQL hostname for a current MySQL connection using this query:
SELECT @@hostname hostname;
display a process list for a MySQL database server by using a simple MySQL command:
SHOW FULL PROCESSLIST;
MySQL CONCAT Multiple Rows Into a Single Row
Example will CONCAT multiple rows into a single row:
SELECT id, subject, GROUP_CONCAT(username SEPARATOR ', ') usernames FROM some_table GROUP BY id, subject
Date Formatting in MySQL
Here is an example of how to use date formatting in MySQL:
SELECT DATE_FORMAT(dateField, '%m/%d/%Y') AS 'display_date'
FROM example_table;
Will something like:
3/14/2009
SHOW VARIABLES;
will list all variables
select @@version;
display the MySQL hostname for a current MySQL connection using this query:
SELECT @@hostname hostname;
display a process list for a MySQL database server by using a simple MySQL command:
SHOW FULL PROCESSLIST;
MySQL CONCAT Multiple Rows Into a Single Row
Example will CONCAT multiple rows into a single row:
SELECT id, subject, GROUP_CONCAT(username SEPARATOR ', ') usernames FROM some_table GROUP BY id, subject
Date Formatting in MySQL
Here is an example of how to use date formatting in MySQL:
SELECT DATE_FORMAT(dateField, '%m/%d/%Y') AS 'display_date'
FROM example_table;
Will something like:
3/14/2009
SHOW VARIABLES;
will list all variables
select @@version;
No comments:
Post a Comment