Question : Show result query

Hey guys,

what am I doing wrong here? It's a very simple script.
Oo and, is my query correct? (I'm not that good with joins)

1:
2:
3:
4:
5:
6:
7:
$lyricID = 3;
$getlyric_sql = mysql_query("SELECT lyrics.lyricID, lyrics.lyrictitle, lyrics.lyric, artists.artistname, albums.albumname FROM lyrics INNER JOIN artists, albums ON lyrics.artistID = artist.artistID AND lyrics.albumID = albums.albumID WHERE lyrics.lyricID = '".mysql_real_escape_string($lyricID)."'");

while($row = mysql_fetch_array($getlyric_sql, MYSQL_ASSOC))
	{
		echo $row['lyrictitle'];
	}

Answer : Show result query

Are you trying to do a CROSS JOIN with albums and artists? If not, I don't think this is proper JOINs. See below for how I interpret this based on the columns you are joining currently. Just showed the SQL to make it clearer -- easier to read. The ly, ar and al are just aliases to the actual tables that way you avoid having to write out every time and as such avoid misspelling like artist instead of artists.
1:
2:
3:
4:
5:
6:
SELECT ly.lyricID, ly.lyrictitle, ly.lyric, ar.artistname, al.albumname 
FROM lyrics ly
INNER JOIN artists ar ON ly.artistID = ar.artistID
INNER JOIN albums al ON ly.albumID = al.albumID 
WHERE ly.lyricID = 'somevalue'
;
Random Solutions  
 
programming4us programming4us