Post by ahmedatwa » Fri Jun 17, 2016 9:31 am

guys I have the below Query to get all order_product table with a result of 73 Order

Code: Select all

$sql = "SELECT op.name AS productname, op.order_id AS order_id, op.quantity AS quantity, op.total AS total, pv.vendorname AS vendorname, vc.commission_type AS commission_type, vc.commission_name AS commission_name, o.currency_value AS currency_value, o.currency_code AS currency_code, op.tax AS tax, os.name AS status, vc.commission AS commission FROM " . DB_PREFIX . "order_product op 
INNER JOIN " . DB_PREFIX . "product_to_vendors pv ON (op.vendors_id = pv.vendors_id) 
INNER JOIN " . DB_PREFIX . "order o ON (o.order_id = op.order_id) 
INNER JOIN " . DB_PREFIX . "vendors_commission vc ON (vc.commission_id = pv.commission_id) 
INNER JOIN " . DB_PREFIX . "order_status os ON os.order_status_id = o.order_status_id
AND o.order_id = op.order_id WHERE op.vendors_id = pv.vendors_id";
What i get is only 40 Order results with duplicate orders NOTE that order # 2024 should get only 5 results matched to DB
Image

New member

Posts

Joined
Sat Mar 05, 2016 5:22 pm

Post by AlexDW » Fri Jun 17, 2016 5:35 pm

Use GROUP BY in query

Useful Opencart extensions


User avatar
New member

Posts

Joined
Sun Jun 05, 2016 3:32 am

Post by ahmedatwa » Sat Jun 18, 2016 1:14 am

Thanks for help

New member

Posts

Joined
Sat Mar 05, 2016 5:22 pm
Who is online

Users browsing this forum: Bing [Bot] and 50 guests