How to make multiple members of an array match an article in a MySQL single field.
For example
Array:
$arr =array (' Tom ', ' Cat ', ' jam ', ' Tim ', ' Bim ');
The contents of the article fields in MySQL are as follows
First string
Tom,cat,tony,girl
Second string
Jam,tim,bim
Third string
Jam,tom
Fourth string
Tool,wood,boy,cat
Through this array, how to match all the following four lines
------to solve the idea----------------------
$sql = ' Create temporary table T ';
foreach ($arr as $i = = $v) {
$sql. = $i? "Union Select ' $v '": "Select ' $v as name";
}
mysql_query ($sql); Create a temporary table
$sql = "SELECT * from Tbl_name, T where Find_in_set (T.name, Tbl_name.field)";
$rs = mysql_query ($sql); Inquire
------to solve the idea----------------------
If the query is more full-text search, the most direct and fast,
Besides, your words are separated by commas, so the word breaker is especially easy.
------to solve the idea----------------------
The following string is converted into an array, compared to the above array, and if the array has the same element, the current string is recorded.