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

  • SEARCH
  • Home
  • 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 8565989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:33:16+00:00 2026-06-11T17:33:16+00:00

My system stores products from many different e-shops and I need to pair products

  • 0

My system stores products from many different e-shops and I need to pair products according to their names. For example:

INPUT: MySQL table products

id | name                       | id_seller
1    porsche 911 red edition      1
2    red porsche 911 gt           2
3    icecream                     1

DESIRED OUTPUT: Suggestion that product 1 is similar to product 2.

In the first step it would be sufficient to make suggestions just on the number of common words – 3 out of 4 in this Porsche example.

More sophisticated solution would involve comparing the order of words not just their occurrences, but I guess it wouldn’t be trivial.

Can it be done using just MySQL query and its built-in functions or any sophisticated library/add-on has to be used?

  • 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-06-11T17:33:17+00:00Added an answer on June 11, 2026 at 5:33 pm

    Here is a SQLFiddle example to find pairs of products with at least one common word in the name column:

    select t.id id1, t.name name1, t1.id id2, t1.name  name2 from t
    join t t1
    where t.id<t1.id
          AND
          t.name regexp 
            CONCAT('([[:<:]]',
                   REPLACE(
                       TRIM(t1.name),
                       ' ',
                       '[[:>:]]|[[:<:]]'
                   ),
                   '[[:>:]])');
    

    If you need to find lines with at least N common words you should create tmp table splitting each row to words. Here is an example and stored procedure to do it. For your example this table looks like:

    id | name                       
    1    porsche
    1    911
    1    red
    1    edition      
    2    red
    2    porsche
    2    911
    2    gt           
    3    icecream                     
    

    in this case you can use following query to find id’s with at least N common words (in this case N=3):

    select t1.id,t2.id,count(*)
    from tmp t1,tmp t2
    where t1.id<t2.id and t1.name=t2.name
    group by t1.id,t2.id having count(*)>=3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system running Coldfusion8/MySQL 5.0.88 . On some pages I need to
I have a system right now that stores products and tags that are associated
I'm trying to create an XML importer to load products from a POS system
I inherited a system that stores default values for some fields in some tables
I have a system that stores vectors and allows a user to find the
Which is the correct name for a system which stores versions of source code,
I am planning to build a cassandra store system and also I need a
Android System has a builtin certificate Store. The certificates from this store are for
I need store multiple currencies on my database... Here's the problem: Example Tables: [
I'm trying to develop a system using MySQL and PHP. I'm using mysqli* function

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.