Forum Moderators: open
$this->queryItemCnt = "SELECT o.orders_id, op.products_id as pid, op.products_model as modelid, op.orders_products_id, op.products_name as pname, sum(op.products_quantity) as pquant, sum(op.final_price * op.products_quantity) as psum, op.products_tax as ptax FROM " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op WHERE o.orders_id = op.orders_id and op. products_stock_detail = '0' and op. manufacturers2_id = '21' or op. manufacturers2_id = '22'";
The part I bolded is what's causing duplicate content. Basically what happens is; when I remove that, the script works perfectly.
If I try to add it back, everything is multiplied by 2.
a) surround your OR clause in parens as in:
WHERE o.orders_id = op.orders_id and op. products_stock_detail = '0' and (op. manufacturers2_id = '21' or op. manufacturers2_id = '22')";
or
b) convert to using IN as in:
WHERE o.orders_id = op.orders_id and op. products_stock_detail = '0' and op. manufacturers2_id IN ('21', '22')";
If that doesn't work please provide a little more info about how the TABLE_ORDERS and TABLE_ORDERS_PRODUCTS tables are related (foreign keys, main fields, etc.)
NOT IN on the other hand I typically avoid.
Glad it worked.