views:

27

answers:

1

News

nID  nTitle
-----------
1    test

Keyword

kID kWord nID
--------------
 1   abc   1
 2   def   1
 3   ghj   1

So i fetch it like

$sql = mysql_query("SELECT * 
                      FROM news as n, 
                           keyword as k 
                     WHERE n.nID = k.nID");

PHP

while($row = mysql_fetch_array($sql)) {
echo "<div>".$row['nTitle']." - ".$row['kWord']."</div>";
}

As you can see, this will output 3 rows of same title with 3 different keyword. Output :

test - abc
test - def
test - ghj

What i would like to have it

test - abc def ghj
+1  A: 
SELECT GROUP_CONCAT(kWord) FROM News NATURAL JOIN Keyword GROUP BY News.nID

But what's the interest ?

MatTheCat