I have a raw sql query which is always giving error while executing. Here is my query
Users.objects.raw('select target, username from users where location like \'%s%%\' and date(modified) = \'2011-06-14\'',[location])
I am taking the location = 'BUILD'
Location values would be 'BUILD_A', 'BUILD_B','BUILD_C'.
When I am executing the raw sql, below is the error I am getting.
DatabaseError: (1064, "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 'BUILD'%' and date(modified) = '2011-06-14'' at line 1")
In MySQL terms I need to execute the following query:
Select target, username from users where location like 'BUILD%' and target = '2011-06-14'
I have googled it but could not able to get it. Please some one help me