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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.