I have a raw sql query that always gives an error on execution. Here is my request
Users.objects.raw('select target, username from users where location like \'%s%%\' and date(modified) = \'2011-06-14\'',[location])
I take location = 'BUILD'
Location values will be "BUILD_A", "BUILD_B", "BUILD_C".
When I execute raw sql, the error below is what I get.
DatabaseError: (1064, "You have an error in the SQL syntax, check the manual that matches your version of MySQL server for the correct syntax to use next to 'BUILD'% 'and date (changed) =' 2011-06-14 '' on line 1 ")
In terms of MySQL, I need to execute the following query:
Select target, username from users where location like 'BUILD%' and target = '2011-06-14'
I was looking for him, but could not get it. Please help me
source
share