I have run into this issue before but for the life of me I cannot remember how I dealt with it. I have the following query I need to use:
cursor.execute('''SELECT CASE WHEN GROUP_CONCAT(territory) NOT LIKE '%,%' THEN 'XXX' END
FROM myTable
WHERE i.id = %s AND territory_id=%s''', (self.pk, territory))
How do I escape the '%,%'
in the sql query? Basically, I'm trying to find if the group_concat
contains multiple elements.