www.webdeveloper.com
Results 1 to 2 of 2

Thread: Find similar records

  1. #1
    Join Date
    May 2010
    Posts
    168

    Find similar records

    Okay, this one stumped me.

    We have an oracle 9 database, and I'll eventually be using PHP 5.2.x to eventually do the update, but for now, I'm using Oracle SQL*Plus.

    At this stage, we're looking to remove nearly duplicate entries.

    As a simple example, suppose we had a table of male first names and would like to identify names such as 'Doug' vs 'Douglass' and candidates, as well as any other name that starts similarly or at least has a number of letters in common, such as 'Fred' and 'Frederick' and 'Greg' and 'Gregory'.

    Any ideas?

  2. #2
    Join Date
    May 2010
    Posts
    168
    Figured it out:

    Code:
     SELECT NAME
       FROM TABLE_NAME a
       WHERE EXISTS (
         SELECT NULL
         FROM TABLE_NAME b
         WHERE a.NAME LIKE CONCAT( SUBSTR( b.NAME, 1, 4), '%')
         AND a.NAME != b.NAME
       )

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles