Hi I have the following query to Database. It is working correctly in SQL, but not working in python. How to solve this? Thanks in advance.
SELECT distinct id , id FROM XX WHERE id LIKE '01%' GROUP BY id
Double the % to escape it, as Django treats it as a format string where % characters have special meaning:
SELECT distinct id, id FROM XX WHERE id LIKE '01%%' GROUP BY id
-- ^^
invalid literal for int() with base 10: 'XX'