ecroskey Posted December 21, 2004 Posted December 21, 2004 I need to limit the number of rows the following query reads. $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED); I have one product that gets ordered A LOT and the page load time is ridiculous because the above query is looking for all of the customers who ordered this and something else. How do I limit this to say find the first 50 records and then stop the query? I have tried using LIMIT and COUNT, but neither of those are helping me at all, or maybe I am just putting them in the wrong place. Thanks for the help.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.