Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3758644
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:11:38+00:00 2026-05-19T10:11:38+00:00

Example Data: $address_1 = ‘123 Main St.’; $address_2 = ‘Suite 200’; $phone = ‘1235551212’;

  • 0

Example Data:

$address_1  = '123 Main St.';
$address_2  = 'Suite 200';
$phone      = '1235551212';
$zip        = '12345';

Example Database:

record_id, address_1, address_2, zip, phone
123, '123 main street', '', '12345', '1234567890'
124, '500 E. Ninja Road', 'Suite #200', '12345-1111', '(321)654-0987'
125, '222 where 4 east circle', 'P.O. Box 3', '11111', '1-123-555-1212'

This can be separate queries but I would need to search for partial matches in the address and zip and full matches in the phone.

So
$address_1 would partial match record_id 123 as ‘123 Main St.’ is a variation of ‘123 main street’
$address_2 would match record_id 124 as ‘Suite 200’ is a variation of ‘Suite #200’
$phone would match record_id 125 as ‘1235551212’ is a variation of ‘1-123-555-1212’
$zip would match record_id 123 & 124 as ‘12345’ is a variation of ‘12345-1111’ and a match to ‘12345’

NOTE:
Also the values could be switched, meaning that $address_1 could be formated like this: ‘123 main street’ and record_id 123 could be like this: ‘123 Main St.’ (This applies to all fields)

I have been suggested to try ILIKE, LIKE, SIMILAR, CITEXT and FTS (Free Text Search) all of which are great but I’m not sure how to implement them to get the results I desire.
I don’t mind running multiple queries for each like a query for $address_1 match and another for $address_2 match and so on. I also know that there will be false positives as well as false negatives but I’m hoping to be around 75% (or better) in accurancy.

One IMPORTANT note is that the Postgres Server is running version 7.4 and there are no plans to upgrade.

Also to add more complexity to the query there are multiple address_1, address_2, zip and phone (Think separate address/phone for like home and office)

Here are my first attempts at solving this problem:

  • Stack Question #1
  • Stack Question #2

I had an idea to produce the most common formats and then pass those as the parameters in the query.

Something like:

$address_1  = array(
   '123 Main St.', // original
   '123 main st.', // lower case
   '123 Main St.', // First Letter Upper Case
   '123 MAIN ST.', // ALL Upper Case
   '123 Main St',  // remove punctuation original
   '123 main st',  // remove punctuation lower case
   '123 Main St',  // remove punctuation First Letter Upper Case
   '123 MAIN ST',  // remove punctuation ALL Upper Case  
   '123 Main',     // remove last word original
   '123 main',     // remove last word lower case
   '123 Main',     // remove last word First Letter Upper Case
   '123 MAIN',     // remove last word ALL Upper Case 
   '123 Main%',    // remove last word original with wildcard
   '123 main%',    // remove last word lower case with wildcard
   '123 Main%',    // remove last word First Letter Upper Case with wildcard
   '123 MAIN%'     // remove last word ALL Upper Case with wildcard
);

Then the query would be something like this:

SELECT * 
FROM tbl_name
WHERE address_1 IN (
   '123 Main St.', '123 main st.', '123 Main St.',
   '123 MAIN ST.', '123 Main St', '123 main st',
   '123 Main St', '123 MAIN ST', '123 Main',
   '123 main', '123 Main' '123 MAIN',
   '123 Main%', '123 main%', '123 Main%', 
   '123 MAIN%'
)

Just seems like a ton of variations I would have to make and I’m still not sure if this would be the most optimal way.

UPDATE:

Well this kinda works (from Stack Question #2)

SELECT * 
FROM tbl_name
WHERE LOWER(address_1) ILIKE LOWER('123 Main%')

With using the UNION method (from Stack Question #1) for each addition address field search like Office and Home

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:11:39+00:00Added an answer on May 19, 2026 at 10:11 am

    If I understand you correctly, you need fragmentary matches from field to field (e.g. ‘123″ matches ‘123-111’ and ‘12345’ but not ‘122234’ or ‘122-345’) and you need to avoid all symbols when matching. Is this correct?

    The psuedocode below is what I would try first:

    • Process all input fields to remove symbols
    • Tokenize the fields to determine fragments to match
    • Perform matches on fragments to data values

    It sounds like the best way to achieve this would be through ILIKE queries where the percentage signs are are the beginning and the end of the fragment, such as:

    SELECT * FROM [TABLE_NAME] WHERE address_1 ILIKE '%fragment%'
    

    You would have to perform this query multiple times, which could be a performance headache, but I believe that may get you what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ex: <a><strike>example data in here</strike></a> I want everything inside the a tag, to the
I have some data with messed-up accented characters. For example in the data we
For example when editing various data files, the backup data is no use and
url = http://example.com/file.xml data = urllib2.urlopen(url) data.read() The question is, when exactly will the
For example, referencing something as System.Data.Datagrid as opposed to just Datagrid. Please provide examples
I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example
How does one read a data file in an iPhone project? For example, lets
How do type casting happen without loss of data inside the compiler? For example:
Reporting services use format strings to auto format cell data. For example c2 formats
Is it better to use $.get(http://www.example.com/mydirectory, function(data) { $(.someclass).html(data); }); or $('.tripPlannerBottom').load(http://www.example.com/mydirectory); any speed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.