Sample Header Ad - 728x90

MySQL - Fuzzy Match Text on Each Side of Newlines

0 votes
1 answer
228 views
I am working on an issue where I need to check a street field or exact matches at a minimum but also, if at all possible, fuzzy matches. For example, if I have address 1234 Some Road, it should at least direct match to 1234 Some Road on the other side of the newline. I would also like to match 999 Somewhere Lane and 999 Somewhere Ln. Obviously, addresses won't have identical lengths so it has have some flexibility and there shouldn't be any more than two rows since the website this is on caps it at Address 1 and 2.
entity_id, parent_id, customer_address_id, quote_address_id, concat(firstname, ' ', lastname) as 'name', street, city, region, postcode from sales_order_address where (street regexp "\n" or street regexp "\r" or street regexp "\r\n");
This query found all rows with any type of newline but as stated above, I need to match the newlines as though they're unique 'rows'. This comment - https://stackoverflow.com/a/50490998/18582667 - seems to imply this kind of matching is possible, but I haven't found a definitive answer to that anywhere. Even if I can't fuzzy match, a direct match will be fine and will help me locate street fields with an issue. I'm also fine with a roundabout way of matching so it doesn't need to be super concise. What are my options, if any?
Asked by Marisa (23 rep)
May 18, 2023, 03:32 PM
Last activity: Jun 10, 2025, 04:08 AM