Sql get results only containing all keywords Let's say I have mysql table called SONGS, with columns:

Artist | Featuredartist | Songname | Year

What I need is to get Artist and Songname, only containing my keywords (and no matter how they are sorted):

For example:

ACDC Metallica 2000 (should get me only results of Metallica featured ACDC (or reversed) and only of year 2000.

The same results I should get using query sorted another way, i.e: 2000 ACDC Metallica.

The same with 2 or one keywords, "Metallica ACDC", for example. It should get me results of songs by metallica feat. ACDC and ACDC feat Metallica, of all years.

I have tried to use UNION, but it gets me results containing one of keywords.

$search = "ACDC Metallica 2000"; // or Metallica ACDC or ACDC 2000, etc.
$sql = '';
$count = 0;
foreach($search as $text)
{
  if($count &gt; 0){

     $sql = $sql."UNION Select * From songs WHERE artist LIKE '%$text%' and featuredartist LIKE '%$text%' and year MATCH '%$text%'";

  }else{

     $sql = $sql."Select * From songs WHERE artist LIKE '%$text%' or featuredartist LIKE '%$text%' and year MATCH '%$text%'";

  }
  $count++;
}


How could I achieve this?
I have found the answer and I will write it here as it may be useful for someone.

First I have altered tables by marking it up on Mysql database and clicking "Fulltext". 

To use multiple keywords, use this code (which will get ) before mysql query (in php):

$search="ACDC 2000"; // any keyword 
$search=explode(' ', $search );
$Asearch = array();
foreach($search as $result) {
    $Asearch[] .= '+'.$result.'*';
}


Then use this mysql query:

SELECT * FROM songs WHERE MATCH(artist,featuredartist,year) AGAINST('".join(' ',$Asearch)."' IN BOOLEAN MODE)


You will get only results which include all entered keywords.