-
Finding Duplicates using SQL
While migrating old data to a new database schema I was unable to activate a PRIMARY KEY on the legacy_customer_id field because there were duplicates. It turned out that the old application did not clean the data really well, and it allowed duplicates to be created where one of the customer_ids had a space character […]
-
Using JOIN within the Zend Framework
I found documentation very sparse on the subject of using JOIN with the Zend Framework. So i set out on a quest of many hours figuring out how to get it to work. Here is what I ended up with. I do not claim that this is the best way to do it, or that […]
-
MySQL FIND_IN_SET
I was faced with a field in the database that had a comma separated list of INT’s with a space after the comma. The application searched this field to generate the recordset to display on a web page. First I tried using LIKE, with something along this line: ($state_id is being passed by PHP) SELECT […]
-
MySQL ADDDATE or DATE_ADD
This weekend I needed a couple of MySQL query items that were out of the ordinary, so I thought I would write about them. ADDDATE or DATE_ADD both work the same, but came in very handy. I was struggling with an application where I need to have the date 42 days from now. PHP doesn’t […]
-
Cleaning duplicate records with SQL
I needed a way to clean out a MySQL table of records with duplicate email addresses. To do this I used a simple SELECT query inside of an INSERT. INSERT INTO good_users(email) SELECT DISTINCT(email) FROM bad_users