문제

I have a string in the form $string = 'London,Paris,Birmingham' and I want to search multiple columns for occurences of these values.

For example WHERE events.name, events.cities, events.counties IN (".($string).")

Can someone recommend me a simple and short way of doing something like this.

도움이 되었습니까?

해결책

Use the FIND_IN_SET function:

WHERE (   FIND_IN_SET(events.name, mysql_real_escape_string($string)) > 0
       OR FIND_IN_SET(events.cities, mysql_real_escape_string($string)) > 0
       OR FIND_IN_SET(events.counties, mysql_real_escape_string($string)) > 0)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top