SQL

Database resources

Database admin – super simple, one file

Takes about 1 minute to install.  Now we don’t need to screw around with control panel access all the time if we don’t want to.

http://www.adminer.org/

Adding a split string function to mysql

Function

CREATE FUNCTION SPLIT_STR(
 x VARCHAR(255),
 delim VARCHAR(12),
 pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
 LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
 delim, '');

Usage

SELECT SPLIT_STR(string, delimiter, position)

Query To Find Duplicate Keys

SELECT Id, COUNT(*) AS NoOccurances FROM TABLE GROUP BY Id HAVING COUNT(*) > 1