MySQL backslash apostrophe
I'm having a MySQL issue.
I'm trying to select all rows in a table that start with a backslash and an apostrophe:
SELECT * FROM table WHERE name like '\\\'%'
But this is not working. An example of what I'm trying to select: \'S-GRAVENDEEL
How do I do this?
T开发者_如何学运维hanks
p.s. Yes, this was the result of a faulty import, I know, but now I need to fix it :-)
You need more backslashes:
select * from table where name like '\\\\\'%'
You need one of them to get a single quote into the pattern. Then you need four more to get a single literal backslash down to the like
. Or you could escape the single quote by doubling it:
select * from table where name like '\\\\''%'
So I've got a solution.
Basically what I want to do is fix the entries, so I'll show you what the replace looks like:
SELECT *, REPLACE(naam, '\\''', '''') naamnew FROM school_plaats WHERE naam like '%\\''%'
Apparently, I need to escape the apostrophe with an apostrophe and the backslash with a backslash.
精彩评论