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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.