Username:   Password:  

Get all MySQL rows that are one week old

SELECT DATE_SUB(date_time_column, INTERVAL 1 WEEK) FROM your_table;

Tags

MySQL timestamp date_sub

Order MySQL result by occurence of a field

SELECT
 `row`,
 COUNT(row) AS `count`,
FROM
 `table`
GROUP BY
 `row`
ORDER BY
 `count`;
 
 

Sometimes it is necessary, to sort the rows of a MySQL select statement by the occurence of a field value.

Tags

MySQL count database select order occurences

MySQL create databases script

CREATE DATABASE mydb_development;
CREATE DATABASE mydb_test;
CREATE DATABASE mydb_production;
GRANT all ON mydb_development.* TO 'my_username'@'localhost';
GRANT all ON mydb_test.* TO 'my_username'@'localhost';
GRANT all ON mydb_production.* TO 'my_username'@'localhost' identified BY 'my_password';

Make a SQL script that creates 3 databases and assigns all rights to my_username.

Tags

MySQL create database