select, as BidId, product_master.SmallDescription , product_master.Description, countdownSeconds, product_master.ProductName, product_master.ProductCode, product_master.Image,bid_master.CurrentBid,bid_master.UserName,TIMESTAMPDIFF(second,now(),BidEndTime) as timer , bid_master.MinimumSellingPrice , bid_master.EndPrice from product_master join bid_master on where BidStatus=1 and TIMESTAMPDIFF(second,now(),BidEndTime)>0 and bid_master.ProductID= order by id asc 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 'order by id asc' at line 1