Need Help in MySQL LEFT JOIN Display Issue


i'm trying to display a MySQL query correctly on a web page.

i have 4 simple tables that connected together

`singers`: `singer_id`, `singer_name`

`songs`  : `singer_id`, `song_name`, `album_id`

`albums` : `singer_id`, `album_id`, `album_name`


i already managed to get those tables using this query.

    SELECT singers.singer_name, songs.song_name, albums.album_name

	FROM singers 
	LEFT JOIN songs ON singers.singer_id = songs.singer_id
	LEFT JOIN albums ON albums.album_id = songs.album_id
	WHERE singers.singer_id = ?
	ORDER BY songs.song_id DESC



the problem i'm having now is that i cant seem to display those tables right.

lets say i have a singer with 1 album and 11 songs.
this is the result i'm getting for this singer.


    singer_name  |     song_name     |     album_name
    __________________________________________________
    
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name

so instead of getting 1 album i'm getting the same album 11 times.

on the web page i'm displaying the albums using `foreach()`
and i'm getting the same album instead of just one album.

now for the question....

How can i display the album ONLY 3 times?

(without hard coding because i might have a singer with 9 albums as well).

thanks in advance for any help.



Need Help in MySQL LEFT JOIN Display Issue
===



i'm trying to display a MySQL query correctly on a web page.

i have 4 simple tables that connected together

`singers`: `singer_id`, `singer_name`

`songs`  : `singer_id`, `song_name`, `album_id`

`albums` : `singer_id`, `album_id`, `album_name`


i already managed to get those tables using this query.

    SELECT singers.singer_name, songs.song_name, albums.album_name

	FROM singers 
	LEFT JOIN songs ON singers.singer_id = songs.singer_id
	LEFT JOIN albums ON albums.album_id = songs.album_id
	WHERE singers.singer_id = ?
	ORDER BY songs.song_id DESC



the problem i'm having now is that i cant seem to display those tables right.

lets say i have a singer with 1 album and 11 songs.
this is the result i'm getting for this singer.


    singer_name  |     song_name     |     album_name
    __________________________________________________
    
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name
    singer name  |  song name        |    album name

so instead of getting 1 album i'm getting the same album 11 times.

on the web page i'm displaying the albums using `foreach()`
and i'm getting the same album instead of just one album.

now for the question....

How can i display the album ONLY 3 times?

(without hard coding because i might have a singer with 9 albums as well).

thanks in advance for any help.


