You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and i.channel_type_id = 6 and i.telco_id = 5 and o.sms_cat_id = 3 limit' at line 28[ select c.click_id, f.affiliate_id, f.affiliate_code, f.validate_code, g.campaign_title, s.service_id, s.service_name, coalesce(t.shortcode, s.shortcode) as shortcode, coalesce(t.keyword, s.keyword) as keyword, coalesce(t.ivr_code, s.ivr_code) as ivr_code, i.interface_id, o.price, p.page_id from wap.aoc a join wap.click c using (click_id) join wap.click_tag t using (click_tag_id) join wap.hit h using (hit_id) join wap.page p using (page_id) join wap.affiliate f using (affiliate_id) join wap.campaign g on g.campaign_id = t.campaign_id join message_service.service s using (service_id) join message_service.incoming_channel i using (service_id) join message_service.telco_service t using (service_id, telco_id) join message_service.outgoing_channel o using (interface_id, service_id) where a.aoc_id = and i.channel_type_id = 6 and i.telco_id = 5 and o.sms_cat_id = 3 limit 1]