• Finding Duplicate Fields in a Database Table

    Occasionally it is necessary to find duplicate fields within a database table.  The following query can be used to accomplish this easily.
    SELECT *
    FROM 'table'
    WHERE ('item' IN (SELECT 'item'
    FROM 'table'
    GROUP BY 'item'
    HAVING COUNT(*) > 1))
    ORDER BY 'item'

    This will list all rows in the desired ‘table’ where the given field (‘item’) is duplicated. This is a great query to use if you want to find duplicate email addresses in a database, or any other field that may be duplicated.

    Read the rest of this entry »

  • Problem Installing Typo Gem

    We have a rails server that we wanted to install the typo gem onto.  Alas, our attempts to install the gem kept failing with the following error:

    Building native extensions.  This could take a while...
    ERROR:  Error installing typo:
    	ERROR: Failed to build gem native extension.
    /usr/bin/ruby1.8 extconf.rb install typo
    checking for fdatasync() in -lrt... yes
    checking for sqlite3.h... no
    make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'.  Stop.

    If you are seeing this error, it means you are likely missing a SQLite3 library or 2. We always use MYSQL, so we did not have any SQLite3 packages installed. Since it was failing on a build, we installed the libsqlite3-dev package. This was all we needed to do and the typo gem installed perfectly with all its dependencies.

    On Ubuntu, do the following to install:

    sudo apt-get install libsqlite3-dev

    Redhat\Centos will be different (for us, substitute apt-get for yum)
    Read the rest of this entry »