Select from table where name Like (single quote?)
Moderator: General Moderators
Select from table where name Like (single quote?)
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..
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
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.
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.