I have some scraped product data in a database which I'd like to use on my website. I want to write a query that gives back all items where title LIKE "%EXAMPLE%" but then only with unique products.
The issue is that I have multiple rows for 1 item and I only want 1 row per product to be returned (I scrape daily so every day every item get's an extra row). The only difference between the rows is that they have another date and price because thats what I scrape for, price history.
Example: We have 3 items: Pink chocolate, Pink apple and Pink pear. Each item has 3 rows because I scraped them 3 times. so for example (for the purpose of this example I did not add all the other columns):
productId | title | price | isAvailable |
---|---|---|---|
ABC123DEF | Pink Apple | 0.47 | 1 |
ABC123DEF | Pink Apple | 0.42 | 1 |
ABC123DEF | Pink Apple | 0.41 | 1 |
ABC333FHG | Pink Pear | 0.41 | 1 |
ABC333FHG | Pink Pear | 0.41 | 1 |
ABC333FHG | Pink Pear | 0.41 | 1 |
FH5845FJG | Pink Chocolate | 0.41 | 1 |
FH5845FJG | Pink Chocolate | 0.41 | 1 |
FH5845FJG | Pink Chocolate | 0.41 | 1 |
The result I want to get is:
productId | title | price | isAvailable |
---|---|---|---|
ABC123DEF | Pink Apple | 0.47 | 1 |
ABC333FHG | Pink Pear | 0.41 | 1 |
FH5845FJG | Pink Chocolate | 0.41 | 1 |
It looks like I have to search on title and then filter out duplicate productId's so that I'm left with the right result. I do not know how to do this though.
any thoughts?