In Laravel, I have a query which is:
$productsModel->join('tags', 'tags.item_id', '=', 'products.id')
->select('products.*', 'tags.item_id')
->distinct();
DB tables looks like this:
| products | tags |
----------|---------|
| id | id |
| | item_id |
products has a one to many relationship with tags, which creates issues when joining tables. As an example, I need to query products based on multiple tags, but I need to show only one product.