Jump to content

searching problem i hope somebody will help me here


lenerd3000

Recommended Posts

hello,

 

i have created a query that is to search text in my database and it goes well. but my friend the other day is complaining that he did not find what he search in the database but actually the data is really in there.. the data contains ampersand(&) like 'tom & jerry' and also a text 'mcs of tampa inc'.

my query is this:

 

select * from mytable where mytext like '%mcs of tampa inc%'

select * from mytable where mytext like '%tom & jerry%'

 

in the first query, it runs ok when the text is 'mcs of tampa' but if i complete it to 'mcs of tampa inc' no results has been return.

 

is theres a special characters their? pls tell me... thank you

Link to comment
Share on other sites

Try the second query again but replace the & with %.  There is a good chance that the ampersand was encoded when it was inserted into the database.

 

select * from mytable where mytext like '%tom % jerry%'

 

Another possibility is that case is your problem.  "Tom" is not the same as 'tom'.  Consider making both the values lower case in the search.  Yes the second lower() is redundant but I'm expecting that the string will be replaced with a variable in your code.

 

select * from mytable where lower(mytext) like lower('%tom % jerry%')

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.