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)
Mysql update row based on a subselect from the same table
Say you have a table ‘Names’ with 2 columns
ID, Name
1, ‘Jason’
2, ‘Nate’
You want to concatenate the last name to the end of the first without having to read the row…
UPDATE Names AS n1, ( SELECT n2.Name FROM Names AS n2 WHERE n2.ID =1 ) AS n3 SET n1.Name = CONCAT( n3.Name, ' Gaetz' ) WHERE n1.ID =1
Result:
ID,Name
1,’Jason Gaetz’
2,’Nate’
Restore Magento DB
Steps to restore a magento database, add these lines before the first CREATE TABLE statement
SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
Query To Find Duplicate Keys
SELECT Id, COUNT(*) AS NoOccurances FROM TABLE GROUP BY Id HAVING COUNT(*) > 1
Recent Comments