Kal
05-04-2007, 03:47 PM
Hi guys,
i have the following select query:
SELECT ct.transaction_id, ct.customer_id, ct.package_id, ct.package_status, ct.level_1, ct.level_2, ct.level_3, ct.level_4, ct.level_5, ct.level_6, ct.level_7, ct.level_8, ct.level_9, ct.level_10, ct.level_1_commission, ct.level_2_commission, ct.level_3_commission, ct.level_4_commission, ct.level_5_commission, ct.level_6_commission, ct.level_7_commission, ct.level_8_commission, ct.level_9_commission, ct.level_10_commission, ct.date, ct.week_number, c.customer_id, c.customer_type, c.business_name, c.home_contact_name, c.deal_date, p.id, p.customer_id, p.cli FROM the_thecommission.commission_transactions ct left join themobi_thecommission.customers c ON ct.customer_id=c.customer_id left join themobi_thecommission.packages p ON ct.package_id=p.id WHERE (ct.level_1 OR ct.level_2 OR ct.level_3 OR ct.level_4 OR ct.level_5 OR ct.level_6 OR ct.level_7 OR ct.level_8 OR ct.level_9 OR ct.level_10 = '$sales_code') and ct.week_number = '$prev_week_number' and ct.package_status = 'Live'
however it needs to be chage slightly because a 'sales_code' can appear in more than one level. how would i re-write the where clause in order for me to do this.
running this at the moment displays all the records, in some cases it's fine because the same sales code exists in all the records but in some the same sales_code only appears in a couple of the records.
thanks in advance
i have the following select query:
SELECT ct.transaction_id, ct.customer_id, ct.package_id, ct.package_status, ct.level_1, ct.level_2, ct.level_3, ct.level_4, ct.level_5, ct.level_6, ct.level_7, ct.level_8, ct.level_9, ct.level_10, ct.level_1_commission, ct.level_2_commission, ct.level_3_commission, ct.level_4_commission, ct.level_5_commission, ct.level_6_commission, ct.level_7_commission, ct.level_8_commission, ct.level_9_commission, ct.level_10_commission, ct.date, ct.week_number, c.customer_id, c.customer_type, c.business_name, c.home_contact_name, c.deal_date, p.id, p.customer_id, p.cli FROM the_thecommission.commission_transactions ct left join themobi_thecommission.customers c ON ct.customer_id=c.customer_id left join themobi_thecommission.packages p ON ct.package_id=p.id WHERE (ct.level_1 OR ct.level_2 OR ct.level_3 OR ct.level_4 OR ct.level_5 OR ct.level_6 OR ct.level_7 OR ct.level_8 OR ct.level_9 OR ct.level_10 = '$sales_code') and ct.week_number = '$prev_week_number' and ct.package_status = 'Live'
however it needs to be chage slightly because a 'sales_code' can appear in more than one level. how would i re-write the where clause in order for me to do this.
running this at the moment displays all the records, in some cases it's fine because the same sales code exists in all the records but in some the same sales_code only appears in a couple of the records.
thanks in advance