ccrevcypsys Posted November 5, 2007 Share Posted November 5, 2007 Ok so i am trying to query the db so that when a user clicks look at all albums it lists only one album. Right now i have these tables |------songs-------| |------albums------| |------artists-----| song_id-----------+ album_id +------ artist_id name +------ song_id customer_id other_info artist_id--------+ and here is the code for my query $productListQuery = "SELECT * FROM ".$glob['dbprefix']."albums a LEFT JOIN ".$glob['dbprefix']."inventory i ON a.song_id = i.productId LEFT JOIN ".$glob['dbprefix']."customer c ON c.customer_id = i.customer_id WHERE deleted = 0"; So right now it shows every song listing. Here is an image Quote Link to comment Share on other sites More sharing options...
Barand Posted November 6, 2007 Share Posted November 6, 2007 The first thing that strikes me as odd is that I'd expect this structure rather than yours [pre] |------songs-------| |------albums------| |------artists-----| song_id +---- album_id +------ artist_id name | artist_id--------+ customer_id album_id --------+ other_info [/pre] where the song contains the album id. Quote Link to comment Share on other sites More sharing options...
ccrevcypsys Posted November 6, 2007 Author Share Posted November 6, 2007 oh ok thank you ill give that a shot Quote Link to comment Share on other sites More sharing options...
ccrevcypsys Posted November 6, 2007 Author Share Posted November 6, 2007 ok so now im using this query but it still pulls the same data... even when i fixed the table. $productListQuery = "SELECT * FROM ".$glob['dbprefix']."albums a LEFT JOIN ".$glob['dbprefix']."inventory i ON i.album_id = a.album_id LEFT JOIN ".$glob['dbprefix'].customer c ON c.customer_id = i.customer_id WHERE ".$like." AND deleted = 0 ORDER BY a.album_id"; Quote Link to comment Share on other sites More sharing options...
ccrevcypsys Posted November 6, 2007 Author Share Posted November 6, 2007 And i need it to only pull any different album from the artists not a listing for every song like it is doing. someone please help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.