我有一個字符串,如Elton 1999
和MySQL表有4個字段:Where field1 + field2 + field3 LIKE「%my_own_string%」?
table(id, name, surname, year)
我必須檢查,加盟這些字段爲「單場」,它包含了我的字符串的所有單詞。
我的意思是:
1 Elton John 1999 -> must return the record 2 Elton Peter 1999 -> must return the record 3 Paris Elton 1999 -> must return the record 4 Elto John 1999 -> must not return the record 5 Elton Pierre 2000 -> must not return the record
我可以與MySQL直接做,或我需要首先獲得所有記錄,並比分析它們在服務器端? (在PHP上,在我的情況下)
P.S.如果我的字符串是1999 Elton,則必須開始相同的結果,所以我的單詞的順序並不重要...
其實我不需要空白。 @Shredder解決方案看起來很棒... – markzzz
+1空間分隔符 –