Monthly Archives: November 2009

Finding Duplicates in MySQL

I get quite a few Excel files from clients that need to get cleaned up and inserted in to MySQL. Sometimes the import goes smoothly, sometimes it doesn’t. This last time, I had 3,741 rows in an Excel file, but somehow wound up with 3,751 rows in the database – what went wrong? Don’t know, and don’t have time to figure it out – so I just used this query to isolate all the duplicates.

My database table consists of nothing more than an id, a part number (number), a description, and a price. Here’s the query that located all duplicate part numbers – from there I was able to easily delete them:

SELECT number, 
 COUNT(number) AS NumOccurrences
FROM part_prices_new
GROUP BY number
HAVING ( COUNT(number) > 1 )

Easily Search a Twitter Stream

Update: this project is no longer active

I occasionally see people wondering how to search their Twitter stream, or anybody’s Twitter stream for that matter. Sure, you can easily search all of twitter for something, but what about limiting a search to a particular user? Twitter’s search features are pretty hit or miss for such specific searches, so as long as the account being searched is public and accessible to anyone, Google will have indexed it much more efficiently than Twitter.

So… I would try to explain how to use Google to restrict a search to a particular website or even part of a website. That wasn’t working so well. So I just made a website that does it for you – Search a Peep’s Tweets. It even remembers your most recent searches for you.

Searc a Peep's Tweets

As a comparison, I used Twitter’s advanced search to search my Twitter account (stoptime) for “beer” -¬† I get no results. The same search on Google gives me 10 results. So hopefully this’ll be useful and easy, cheers!