I am making a price comparing website. I have data from different stores, but I could not find any way to map similar products to single product.
I have a table 'product' like this .
id title brandName | 8986 | Samsung Galaxy Ace | Samsung | 1 | | 8983 | Samsung Galaxy Ace | Samsung | 1 | | 6048 | Samsung Galaxy Ace | Samsung | 1 | | 6109 | Samsung Galaxy Ace | Samsung | 1 | | 9840 | Samsung Galaxy Ace Duos | Samsung | 1 | | 8905 | Samsung Galaxy Ace Duos | Samsung | 1 | | 9097 | Samsung Galaxy Ace Duos | Samsung | 1 | | 765 | Samsung galaxy Ace Duos S6802 ( Black) | Samsung | 2 | | 766 | Samsung Galaxy Ace Duos S6802 (Chic White) | Samsung | 2 | | 11880 | Samsung Galaxy Ace NXT | Samsung | 1 | | 11218 | Samsung Galaxy Ace NXT | Samsung | 1 | | 323 | Samsung Galaxy Ace Nxt G313H Black | Samsung | 2 | | 311 | Samsung Galaxy Ace Nxt G313H White | Samsung | 2 | | 9099 | Samsung Galaxy Ace Plus | Samsung | 1 | | 1153 | Samsung Galaxy Ace Plus S7500 Dark Blue | Samsung | 2 |
Now I want to map similar products; for example I need results like
title brandIDs Samsung Galaxy Ace 8986 , 8983 , 6048 , 6109 Samsung Galaxy Ace Duos 9840 , 8905 ,9097 , 765 , 766 Samsung Galaxy Ace NXT 11880 , 11218 , 323 , 311 Samsung Galaxy Ace Plus 9099 , 1153
Is there any programming logic or mysql which can give me desired result? I tried different mysql clause i.e LIKE'%%' but it returns me whole data.
Edit : I also tried to use group by 'title' an it gave me this result but still does not give desired one . Here is the result . I tried this query .
SELECT id,title,brandName from product where brandName LIKE '%samsung%' GROUP BY title ORDER BY title
id title brandName | 6048 | Samsung Galaxy Ace | Samsung | | 8905 | Samsung Galaxy Ace Duos | Samsung | | 765 | Samsung galaxy Ace Duos S6802 ( Black) | Samsung | | 766 | Samsung Galaxy Ace Duos S6802 (Chic White) | Samsung | | 11218 | Samsung Galaxy Ace NXT | Samsung | | 323 | Samsung Galaxy Ace Nxt G313H Black | Samsung | | 311 | Samsung Galaxy Ace Nxt G313H White | Samsung | | 9099 | Samsung Galaxy Ace Plus | Samsung | | 1153 | Samsung Galaxy Ace Plus S7500 Dark Blue | Samsung |