Query failed: 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 stock_history.date = "2010-08-06"' at line 1