Archive for the 'Web' Category

MySQL remove duplicates

Friday, December 9th, 2011

DELETE n1 FROM table n1, table n2 WHERE n1.id > 10000 AND n1.id < 11000 AND n1.id > n2.id AND n1.EMAIL = n2.EMAIL;

The above MySQL query will delete duplicate email addresses between the id’s 10000 and 11000. Breaking the query into blocks of 1000 id’s will reduce strain the MySQL server.

MySQL find duplicates

Friday, December 9th, 2011

select EMAIL, count(EMAIL) as cnt
from TABLE
group by EMAIL
having cnt > 1 ORDER BY `cnt` DESC

The above MySQL query will find and list the number of multiple duplicate emails in a table.

Search web by image

Monday, November 28th, 2011

http://www.tineye.com/ allows you to search the web for similar images to ones uploaded or on the web.

UPDATE: Google has this as well: http://www.google.com/insidesearch/searchbyimage.html

PHP imagick – website references, manuals and information

Wednesday, September 7th, 2011

imagick is a more advanced graphics library than the default GD for PHP, but the ImageMagick PHP library imagick is only documented on PHP.net comments, so using the library can be a bit challenging, but the sites above help in using the library.

Multiple MySQL query with PHP

Tuesday, May 31st, 2011


// Enter multiple query string
$query_str = "
-- Update table
UPDATE t SET id = id + 1;
-- Insert into table
INSERT INTO example (name, age) VALUES('John Doe', '23' );
";
// Explode string into separate queries
$query = explode(';',$query_str);
// Loop through exploded queries and execute
foreach($query as $index => $sql) {
$result = mysql_query($sql,$conn2) or userDisplayMessage(mysql_error().' '.__FILE__.':'.__LINE__);
}

Or, you can use mysqli (MySQL Improved extension), which has a mysqli_multi_query function.