mySQL搜索模式的组合?

Say i have a single entry in ONE column that is:

apples oranges pears

(assume it can be a infnite amount of fruits, but im just using 3)

I use the search box to search for "apples oranges" and passes the string in the $fruit variable. My search comes up using:

SELECT * FROM fruits WHERE fruitcolumn LIKE '%$fruit%'

However when i search for "oranges apples" or "apples pears", no results come up because the pattern doesn't match any entries. Is there an easy way to search all combinations of patterns?

Ty.

If fruit column contains some arbitrary text then consider to use Full Text Search.

If on the other hand these fruits are some sort of characteristics of an entity then please stop (don't store delimited values in the database) and normalize your data by creating many-to-many table entity_fruits.

You can try something like this

$where='';
$fruit="apples fruit2";
$arr=explode(" ",$fruit);
for($i=0;$i<count($arr);$i++)
{
if($i==0)
    $where=$where." LIKE '%".$arr[$i]."%'";
else
    $where=$where." AND  fruitcolumn LIKE '%".$arr[$i]."%'";
}

echo "SELECT * FROM fruits WHERE fruitcolumn  ".$where;

You must add

SELECT * FROM fruits WHERE <coloumn name> LIKE '%$fruit%'