Jump to content

query help


ccrevcypsys

Recommended Posts

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

songs.jpg

Link to comment
https://forums.phpfreaks.com/topic/76122-query-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/76122-query-help/#findComment-385282
Share on other sites

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";

Link to comment
https://forums.phpfreaks.com/topic/76122-query-help/#findComment-385894
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.