Search opening square bracket in SQL query with LIKE operator


Hi,

In my previous post, I’ve identified an issue of file name with square bracket in Amazon S3 URL wasn’t opening in FireFox.

So my next job was to rename the files, and update the path in database.

I wanted to search how many path has ‘[‘ or ‘]’ bracket in file name (consider attachment as SQL table column name for convenient).

I wrote like:

WHERE attachment LIKE '%[%'

But this will not work. When I see MSDN link I came to know that % and [ are used as wild card characters, and I mixed them!!

Then I thought escaping it might work

WHERE attachment LIKE '%\[%'

Silly huh! finally I came up with following:

WHERE attachment LIKE '%[\[]%'

4 thoughts on “Search opening square bracket in SQL query with LIKE operator

  1. Jake

    When I originally commented I clicked the “Notify me when new comments are added”
    checkbox and now each time a comment is added I get four emails with the same comment.

    Is there any way you can remove people from that service?
    Appreciate it!

    Reply
  2. wallpapers for macbook pro 15

    Hey would you mind letting me know which webhost you’re using? I’ve
    loaded your blog in 3 completely different internet browsers and
    I must say this blog loads a lot quicker then most.
    Can you recommend a good hosting provider at a honest price?

    Many thanks, I appreciate it!

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s