Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Better way of matching a customer address

Better way of matching a customer address

Scheduled Pinned Locked Moved Database
salesregex
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    I'm trying to find a better way of matching an address. So I was thinking, the credit card processors use the street address 1 and zip or postal code to do a AVS match, and perhaps I should just copy that idea. I wrote this, sort of copied it and made some edits But I can't get it right. I can't figure out where to place my input to match against.

    DECLARE @PostalCode VarChar(12), @CustomerID Int, @StreetAddress1 VarChar(80);
    SET @PostalCode = '92648';
    SET @CustomerID = 5;
    SET @StreetAddress1 = '18751 Park Haven Lane';
    SELECT *
    FROM CUSTOMER_SHIPPING_ADDRESS
    WHERE LEFT(@StreetAddress1, 5) IN (
    SELECT LEFT(StreetAddress1, 5)
    FROM CUSTOMER_SHIPPING_ADDRESS
    GROUP BY LEFT(StreetAddress1, 5 )
    HAVING COUNT(*) > 1
    )
    AND PostalCode = @PostalCode
    AND CustomerID = @CustomerID

    J P J 3 Replies Last reply
    0
    • J jkirkerx

      I'm trying to find a better way of matching an address. So I was thinking, the credit card processors use the street address 1 and zip or postal code to do a AVS match, and perhaps I should just copy that idea. I wrote this, sort of copied it and made some edits But I can't get it right. I can't figure out where to place my input to match against.

      DECLARE @PostalCode VarChar(12), @CustomerID Int, @StreetAddress1 VarChar(80);
      SET @PostalCode = '92648';
      SET @CustomerID = 5;
      SET @StreetAddress1 = '18751 Park Haven Lane';
      SELECT *
      FROM CUSTOMER_SHIPPING_ADDRESS
      WHERE LEFT(@StreetAddress1, 5) IN (
      SELECT LEFT(StreetAddress1, 5)
      FROM CUSTOMER_SHIPPING_ADDRESS
      GROUP BY LEFT(StreetAddress1, 5 )
      HAVING COUNT(*) > 1
      )
      AND PostalCode = @PostalCode
      AND CustomerID = @CustomerID

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Oh I think I get it now, should of had a cup of coffee this morning

      DECLARE @PostalCode VarChar(12), @CustomerID Int, @StreetAddress1 VarChar(80);
      SET @PostalCode = '92648';
      SET @CustomerID = 5;
      SET @StreetAddress1 = '18751 Park Haven Lane';
      SELECT *
      FROM CUSTOMER_SHIPPING_ADDRESS
      WHERE PostalCode = @PostalCode
      AND CustomerID = @CustomerID
      AND LEFT(StreetAddress1, 5) = LEFT(@StreetAddress1, 5)

      1 Reply Last reply
      0
      • J jkirkerx

        I'm trying to find a better way of matching an address. So I was thinking, the credit card processors use the street address 1 and zip or postal code to do a AVS match, and perhaps I should just copy that idea. I wrote this, sort of copied it and made some edits But I can't get it right. I can't figure out where to place my input to match against.

        DECLARE @PostalCode VarChar(12), @CustomerID Int, @StreetAddress1 VarChar(80);
        SET @PostalCode = '92648';
        SET @CustomerID = 5;
        SET @StreetAddress1 = '18751 Park Haven Lane';
        SELECT *
        FROM CUSTOMER_SHIPPING_ADDRESS
        WHERE LEFT(@StreetAddress1, 5) IN (
        SELECT LEFT(StreetAddress1, 5)
        FROM CUSTOMER_SHIPPING_ADDRESS
        GROUP BY LEFT(StreetAddress1, 5 )
        HAVING COUNT(*) > 1
        )
        AND PostalCode = @PostalCode
        AND CustomerID = @CustomerID

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        You might also want to look into Levenshtein Distance. Plus, unless you are using an inferior database system, use JOINs rather than subqueries and IN.

        J 1 Reply Last reply
        0
        • P PIEBALDconsult

          You might also want to look into Levenshtein Distance. Plus, unless you are using an inferior database system, use JOINs rather than subqueries and IN.

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          Oh that looks complicated. hmm, Good idea though.

          P 1 Reply Last reply
          0
          • J jkirkerx

            Oh that looks complicated. hmm, Good idea though.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            I had to use Levenshtein a while back to match addresses from two systems. Some times there's no other way.

            J 1 Reply Last reply
            0
            • P PIEBALDconsult

              I had to use Levenshtein a while back to match addresses from two systems. Some times there's no other way.

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #6

              OK. I'll learn from your experience.

              1 Reply Last reply
              0
              • J jkirkerx

                I'm trying to find a better way of matching an address. So I was thinking, the credit card processors use the street address 1 and zip or postal code to do a AVS match, and perhaps I should just copy that idea. I wrote this, sort of copied it and made some edits But I can't get it right. I can't figure out where to place my input to match against.

                DECLARE @PostalCode VarChar(12), @CustomerID Int, @StreetAddress1 VarChar(80);
                SET @PostalCode = '92648';
                SET @CustomerID = 5;
                SET @StreetAddress1 = '18751 Park Haven Lane';
                SELECT *
                FROM CUSTOMER_SHIPPING_ADDRESS
                WHERE LEFT(@StreetAddress1, 5) IN (
                SELECT LEFT(StreetAddress1, 5)
                FROM CUSTOMER_SHIPPING_ADDRESS
                GROUP BY LEFT(StreetAddress1, 5 )
                HAVING COUNT(*) > 1
                )
                AND PostalCode = @PostalCode
                AND CustomerID = @CustomerID

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                jkirkerx wrote:

                AVS match,

                There are specific rules associated with that such as removing all punctuation, using abbreviations for standard names, etc. You can probably google for that that. However those are also intended to match with a credit card and the address. And not just the address. Without some other verification system I doubt just an address match is feasible.

                J 1 Reply Last reply
                0
                • J jschell

                  jkirkerx wrote:

                  AVS match,

                  There are specific rules associated with that such as removing all punctuation, using abbreviations for standard names, etc. You can probably google for that that. However those are also intended to match with a credit card and the address. And not just the address. Without some other verification system I doubt just an address match is feasible.

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  I should of removed all the chars that are not A-Z a-z 0-9 first. Well so far so good, much better than before. I was creating a card record with the billing and shipping address. Worked fine for 10 years. The users on the back end complained about it. Users with no programming experience complained that if they wanted to ship to a different address, they had to create a new card record and enter all the information again. So I split everything up into separate records, and recorded the ID's of each record in the order record. But a problem surfaced with duplicate records, in which I did a horrible job in checking for duplicates. So checking a card record was easy, but checking a address record became more complicated.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups