vicodin Posted July 14, 2008 Share Posted July 14, 2008 Hello all... I am currently using mysql match against for a search on my website, yes i know thats the lazy way but thats all i really need right now.... I am having an issue where it can find anything that has a dash in it. For example TL-100 but it would find TL100 just fine... Any ideas on how i could get it to recognize the dash? Thanks!! Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted July 14, 2008 Share Posted July 14, 2008 stab in the dark, I dont really understand what you are doing but try running a variable containing TL-100 through addslashes() or mysql_real_escape_string() that should escape the input so that mysql recognizes the dash as a literal dash and not a minus or whatever - equates to in sql Quote Link to comment Share on other sites More sharing options...
vicodin Posted July 14, 2008 Author Share Posted July 14, 2008 The things is i need the - cause some of the products names have a - in them... ill probably just put in so it takes the - out but just wondering if there was a way to keep the - in there and have it search able. Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted July 14, 2008 Share Posted July 14, 2008 thats what adding a slash does, tells sql that the - is a literal dash not a mathematic operator edit: so it wont be trying to subtract 100 from TL I hope im making sense Quote Link to comment Share on other sites More sharing options...
.josh Posted July 14, 2008 Share Posted July 14, 2008 sql does not get confused by dash marks if it's wrapped in quotes as a string, which I'm assuming his data is: a string type. As far as the question goes: be more specific. Are you wanting to select all data that has a dash in it? Are you wanting it to be able to find TL-100 whether it has a dash in it or not, as in, you want sql to see TL100 and TL-100 as the same thing? Quote Link to comment Share on other sites More sharing options...
vicodin Posted July 14, 2008 Author Share Posted July 14, 2008 Ok perfect that did it... Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.