Hi Folks,
I've got a "products" table and also a "special_prices" table in a commerce senario.
The products table holds product information with prod_id as the primary key. The special_prices table may contain a special price (discount) for that product. The special_prices table also contains a start stamp (DATE) and an end stamp (DATE).
I want to extract the product and special price ( if any) that is valid for the date range...
for example...
The query to extract the product and (maybe) the special price looks like..
SELECT *
FROM products
INNER JOIN specials USING(prod_id)
WHERE products.prod_id = $prodID
AND prod_enabled = 'y'
LIMIT 1
however, i want to add the date condition... so that's something like.....
SELECT *
FROM products
INNER JOIN specials USING(prod_id)
WHERE products.prod_id = $prodID
AND prod_enabled = 'y'
AND ( specials.special_start <= NOW() AND specials.special_end > NOW() )
LIMIT 1
But if there is no special price within this date range then the query returns 0 results (not even the product)
Any ideas?
Thanks