Page 1 of 1
Select from table where name Like (single quote?)
Posted: Mon Mar 20, 2006 8:18 pm
by GeXus
I'm trying to do a selection on all files from a paticular column that contain a single quote... does anyone know how I would do this? by putting the single quote in the query, it always breaks..
Posted: Mon Mar 20, 2006 9:01 pm
by feyd
your query please.
Posted: Tue Mar 21, 2006 4:55 am
by Maugrim_The_Reaper
Quotes are special characters in SQL - they should be escaped using either \' or in some DBMS (and MySQL later versions) '' - 2 single quotes.
So
My dog's name is Rover.
becomes in SQL
'My dog''s name is Rover.' or 'My dog\'s name is Rover' (strings are surrounded by quotes). Read the manual for your database version and type for the correct escaping method to use. MySQL generally accepts the second in most cases - even for MySQL5 I think.