SQL Database Where Statement Help Please
Posted: Sun Oct 25, 2009 4:06 am
Hi all, I have three tables
Artists. Fields = artist id, artist_name
Albums. Fields = album_id, album_title etc
Songs. Fields = song_title, album_id, artist_id etc
I have managed to get a page listing all albums (creating recordsets), with a link from Albums.album_ID taking me to another page which displays data from Albums and Songs associated with field album ID.
I would like to be able to add data from the Artists table (ie the Artists.artist_name which is linked to the Songs.artist_id) on the linked page. as well but I don't know how to get this. I am using dreamweaver and here is the coding I have used;
SELECT albums.album_id, albums.album_title, albums.album_artist, albums.album_tracks, albums.album_year, songs.song_title, songs.song_track, artists.artist_name
FROM albums, songs, artists
WHERE (albums.album_id = songs.song_album_id) AND (albums.album_id = CD)
and here's the variable
NAME: CD TYPE:Integer VALUE:1 RUNTIME:$_GET["album_id"]
I hope I've explained this OK, I'm new to sql, php so any help or advice would be greatly appreciated. Thanks
Artists. Fields = artist id, artist_name
Albums. Fields = album_id, album_title etc
Songs. Fields = song_title, album_id, artist_id etc
I have managed to get a page listing all albums (creating recordsets), with a link from Albums.album_ID taking me to another page which displays data from Albums and Songs associated with field album ID.
I would like to be able to add data from the Artists table (ie the Artists.artist_name which is linked to the Songs.artist_id) on the linked page. as well but I don't know how to get this. I am using dreamweaver and here is the coding I have used;
SELECT albums.album_id, albums.album_title, albums.album_artist, albums.album_tracks, albums.album_year, songs.song_title, songs.song_track, artists.artist_name
FROM albums, songs, artists
WHERE (albums.album_id = songs.song_album_id) AND (albums.album_id = CD)
and here's the variable
NAME: CD TYPE:Integer VALUE:1 RUNTIME:$_GET["album_id"]
I hope I've explained this OK, I'm new to sql, php so any help or advice would be greatly appreciated. Thanks