Reputation: 562
How to use locate function for string if string is present in database field? I want to find location of "m/l" such string. below query return 0 to me however it is present in database table
SELECT locate('"m\/l":"',field) FROM table_name.
Upvotes: 0
Views: 312
Reputation: 211560
If you're dealing with escaped strings, you may need to crank up the escaping significantly to get it to work. Backslashes are special characters and will be collapsed down.
You may want to try:
LOCATE('"m\\/l":"',field)
LOCATE('"m\\\\/l":"',field)
If this is located inside another string, or two levels of string (e.g. inside JSON itself), you may need a lot of them.
Upvotes: 1