SELECT p.*
FROM Products p
LEFT JOIN offertran ot
ON p.prod_id = ot.prod_id
LEFT JOIN Offers o
ON ot.offer_id = o.id
AND o.dF<=3
AND o.dt>=3
ORDER BY o.id DESC,
p.prod_id ASC
LIMIT 20
Please check the output in fiddle
I want the existing condition as it is and some more added conditions as listed below:
- In this output, I got Offered products are shown first (This is important, after this)
- I want New products - that is sort based on
todaysDate - p.pdate less than 30 days
- Then show the products those have
p.pre != ''
- Then show them who dont have price ie.
p.price ==0
- Then arrange other products by
prod_id DESC
I want all in one, to add those 5 points in this existing query
I hope you got the problem. I need an immediate response. Thanks in advance