Skip to content
Advertisement

How to Add the Quantity of Duplicate Products entries. If the Product Quantity is Less than 8 return it

In my API. I have a product table with attributes

product_id, category_id, item_id, size_id, brand_id, product_price, product_quantity, location_id, product_manufacture, product_expire, created_at

enter image description here

enter image description here

And I am returning the products information’s response of which quantity is less than 8.

JavaScript

Here I am previewing data in client side.

enter image description here

This is code which is returning the product information.

JavaScript

But I have same product entries more than one times in database, the different between thus is product manufacture date.

Here I want to return the information after comparing like, if category_id,item_id,size_id and brand_id is same take the quantity of each product add it, and then only if the quantity is less than 8, return it.

enter image description here

How can I do this?

  • Thanks.

Advertisement

Answer

The Problem has been solved by using SUM() and group by in query.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement