我有两个 Table 'movies' 和 movie_embeds
在电影中
id 标题描述
1 Movie1 Desc1
2 Movie2 Desc2
3 Movie3 Desc3
In movie_embeds
id movie_id link
1 1 link1
2 1 link2
3 1 link3
4 2 link4
5 2 link5
6 3 link6
代码:
$sql = "SELECT *
FROM movies, movie_embeds
WHERE movies.id = movie_embeds.movie_id
GROUP BY movies.title ";
$result = mysql_query($sql) or die('A error occured: ' . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo '<p>';
echo $row['title'];
echo '<p>';
echo $row['link'];
echo '<p>';
echo $row['meta'];
echo '<p>';
}
结果:
Movie1
link1
Desc1
movie2
link4
Desc2
movie3
link6
Desc3
问题是我怎样才能在第一个和其他结果中拥有 link2 和 link3?
如果我删除 GROUP BY movies.title 电影标题并且全部重复 3 次。帮助?
我需要这样的结果
我需要这样的结果:
Movie1
link1
link2
link3
Desc1
movie2
link4
link5
Desc2
movie3
link6
Desc3