select a.*,c.id as launched_id, b.subject, b.add_unsub_link, b.message, b.mail_type, d.subs_name, d.subs_email, d.id as subs_id, d.php_sess_id, b.id as message_id from ecom_auto_campaign_tb a,ecom_auto_messages_tb b,ecom_auto_launched_tb c,ecom_auto_subscribers_tb d where a.id = b.campaign_id and b.id = c.message_id and d.id = c.subscriber_id and c.set_date <='2010-03-13 05:49:00' and a.status = 1 and b.status = 1 and d.status = 1 and c.launched_status = -1 and d.validate = 1 and a.merchant_id = order by c.set_dateYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by c.set_date' at line 1