The equivalent character is', so you will need to replace the quote with two quotation marks.
For example,
SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'
becomes
SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe'
However, it is probably wrong to do it yourself. Your language may have a function to avoid strings for use in SQL, but it is even better to use parameters. This usually works as follows.
Your SQL team will:
SELECT * FROM PEOPLE WHERE SURNAME=?
Then, when you execute it, you enter the O'Keefe parameter as the parameter.
Since SQL is parsed before the parameter value is set, there is no way to change the parameter value in the SQL structure (and this is even a little faster if you want to run the same statement several times with different parameters).
I should also note that although your example just causes an error, you open yourself up to many other problems without avoiding the relevant lines. See http://en.wikipedia.org/wiki/SQL_injection for a good starting point or the next classic xkcd comic .

Matt Sheppard Aug 27 '08 at 8:17 2008-08-27 08:17
source share