lenerd3000 Posted March 6, 2008 Share Posted March 6, 2008 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 https://forums.phpfreaks.com/topic/94727-searching-problem-i-hope-somebody-will-help-me-here/ Share on other sites More sharing options...
fnairb Posted March 6, 2008 Share Posted March 6, 2008 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 https://forums.phpfreaks.com/topic/94727-searching-problem-i-hope-somebody-will-help-me-here/#findComment-484974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.