Can I search for 1 AND 2 AND 3 without getting a false match because 11,22,33 are in the field?
A field that has the string = “11,22,33” should then not return any results.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, using comma separated values in a field is problematic, and you should consider storing them in a sepatate table instead. Then you could get the record more efficiently:
If that is not possible, you have to go the slow string matching way. To match the values in a comma separated string, you can use the
likeoperator:Putting the separator on both sides of the searched value makes sure that you don’t get any false positives. Adding the commas before and after the field value makes sure that you can find the first and last value.