I am trying to put together a mysql query for my old 1.5.6.4 Opencart store, the query should get the lowest value on oc_product_special, between certain date interval. I tested my query in phpmyadmin, it works but I cannot insert it into the model. This is my query: SELECT MIN(price) FROM oc_product_special WHERE product_id = xxxx AND date_end > DATE(NOW() - INTERVAL 30 DAY)
And this is my code in model, first part is working (before AND):
Code: Select all
$this->db->query("SELECT MIN(price) AS min_price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'") . "' AND date_end > date_end > DATE(NOW() - INTERVAL 30 DAY);

Thanks!