Jump to content

[SOLVED] Like Function not working with single quotes


Tsukiyomi

Recommended Posts

I've tried two different queries.  The first one does not work, but the second one does.  The only difference I can see between the two is the single quote in the first statement.  For whatever reason the LIKE statement doesn't seem to be working when the string contains and escaped single quote.

 

query = SELECT * FROM tablename WHERE (business LIKE '%Angel\'s daycare%' AND category LIKE '%In Home Daycare%' ) AND (status = '1'  AND status_2 = '1')  LIMIT 0, 10

 

query = SELECT * FROM tablename WHERE (business LIKE '%Obie Family Daycare%' AND category LIKE '%In Home Daycare%' ) AND (status = '1'  AND status_2 = '1')  LIMIT 0, 10

 

Is there any workaround for this?

Never mind I solved it.  Since Angel's daycare was stored like this in the database "Angel\'s Daycare" (since I escaped the quotes in the insert query) I had to escape the quote twice this time so it would look literally for "Angel\'s Daycare".

 

Thanks for the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.