I am trying to retrieve the products (tbl_product) which have an offer going on from tbl_offers
columns in tbl_offers
offerid,productid,discountrate,dateadded,days
where offerid and productid are auto-incremented ids, discountrate is int, dateadded timestamp and days int.
What it basically means an offer is valid for say 10 days after it is added. Days can have different values.
the following is the query i am trying:
select a.* from tbl_product a, tbl_offers b
where a.productid=b.productid and
date_add(dateadded, interval (select days from tbl_offers) day)>NOW();
throws an error saying subquery returns more than one row.
I am confused as to how to target my query to get days from the subquery
You do not need sub-query and using join it could be done