Home » Archive by category 'MySQL'
a_connect on January 14th, 2010

Quick and easy code to convert the character set of a MySQL table to UTF-8. Of course this works for all character sets not just UTF
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Continue reading about Converting MySQL tables to UTF-8

a_connect on July 15th, 2009

Just a quick reminder and example to myself really for this useful MySQL string function.
Syntax:
REPLACE( table_field, search, replace)
Example (replaces all instances of donkey with horse:
UPDATE `table` SET `table_field` = REPLACE( `table_field`, ‘donkey’, ‘horse’)

Continue reading about MySQL REPLACE Function

a_connect on July 1st, 2009

I recently rebuilt the Cornwall24 website in the hope that upgrading from a 3 year old verwion of PostNuke to a new version of Wordpress might stop the site taking down the server by overloading MySQL at least once a week.
Unfortunately it actually made things worse!
So I decided to take the bull by the horns [...]

Continue reading about Speeding up MySQL

a_connect on June 22nd, 2009

Here’s an SQL query that’ll return all the duplicate rows in your table.
SELECT `id`, COUNT(*) as `dup`
FROM `table_name`
GROUP BY `id`
HAVING `dup` > 1
ORDER BY `dup`

Continue reading about Find Duplicate Rows Query

a_connect on June 20th, 2009

The problem:
What I wanted to do here was find a way of speeding up a query that was run on MySQL database on a different server. Also I’m a big fan of caching generally, especially when the data is only updated once or twice a day.
When I was running the queries directly off the remote [...]

Continue reading about Caching remote MySQL queries with PHP