chemfree Posted July 27, 2008 Share Posted July 27, 2008 A filed in my data has some words that are imported with quote marks on either side of the word. I need to be able to search the records to find the rows containing them as well as those which don't. The data may look someting like: Alfred "T" or Alfred T. When I use 'like %string%' in the WHERE clause of the SQL and use 'Alfred "T" as the search input, I get no results. However, if I use '"' as the search input, Alfred "T" will be found. If, I use 'Alf' as the string input, MySQL finds 'Alfred T', but not 'Alfred "T"'. I do not want to strip the quote from the data as they are unique names that may include the quote" What should my SQL look like to find names with or wihout the quote in the field? Thanks! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 27, 2008 Share Posted July 27, 2008 try something like SELECT IF(T1.Fieldname LIKE '%STRING%', '1', '0') as Match, T1.PRIMARYKEY as RowID FROM `TABLENAME` as T1 That should get you all rows and then if it matches the "string" return a 1 or else a 0 to tell you matching/non matching rows. Quote Link to comment Share on other sites More sharing options...
chemfree Posted July 27, 2008 Author Share Posted July 27, 2008 Thanks, I should, probably mentioned that I'm using php to process the code from a web page. So, I'm not sure if that would change your response. Michael 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.