Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

SQL Problem


Recommended Posts

Hi all,


i have a little :'( Problem with an SQL Query.


so first what it should do.


it should look in orders, orders_status_history, and order_products_attributes


when order_status of the order is 4 then look in the order_status_history for the value 4 in the new_value and get the date from date_added then look for the value 2 in new value and get the date from date_added , look in the order_products_attributes for the value month and calculate if the date_added from value 4 - date_added from value 2 is grater then the value 2 date added + the months from the opa.


Here is the query which i have


tep_db_query("select o.customers_id, o.orders_id, osh.date_added, DATE_ADD(osh.date_added, INTERVAL opa.products_options_values MONTH) as end_date from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS_HISTORY . " osh, " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa where o.orders_status = '4' and (o.orders_id = osh.orders_id and o.orders_id = opa.orders_id) and osh.new_value = '2' and (TO_DAYS(NOW()) - TO_DAYS(DATE_ADD(osh.date_added, INTERVAL opa.products_options_values MONTH)) >= 0)");


but it don´t work


i always get wrong results.


anyone can help.



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...