I have a LIKE query I'm running on a column of Android Uri
which are formatted like such:
- content://com.android.externalstorage.documents/tree/0000-0000%3A_Issues/document/0000-0000%3A_Issues%2FParentB
- content://com.android.externalstorage.documents/tree/0000-0000%3A_Issues/document/0000-0000%3A_Issues%2FParentA
- content://com.android.externalstorage.documents/tree/0000-0000%3A_Issues/document/0000-0000%3A_Issues%2FParentA%2FParentB
These correspond to this file tree:
_Issues
|-ParentA
|-ParentB
|-ParentB
I have attempted all sorts of manual queries escaping the wildcards, but I can't seem to get a proper match. I simplified it down to this for testing:
select name from meta where parent LIKE '%_Issues%2FParentB%';
- If I escape '%':
%_Issues\%2FParentB%'
I get no results at all.
- If I don't escape:
'%_Issues%2FParentB%'
I match both the shallow ParentB (desired) and the nested ParentB (undesired). I understand that's because I'm allowing anything between Issues and ParentB with the %.
What I don't understand is why query 1 does has no results. What am I missing?
Update
select name from meta where parent LIKE '%_Issues_2FParentB%';
worked, note the '_', so the '\' was clearly not escaping this db. Explicitly stating the escape character as @GordonLinoff suggested worked on my computer:
select name from meta where parent LIKE '%_Issues\%2FParentB%' escape '\';
Now to figure our how to accomplish the same in Android...