Reputation: 53
I am going to try and explain this the best way I can. I have a table called albumAccess which has the following fields : id, albumID, userID, and permission.
Next I have another table that holds information for each album based off of the albumID.
I want to know how I can use the userID to get all of the album information. I have been researching joins and php arrays but not sure how to go about doing it.
Any help will be appreciated!
Upvotes: 0
Views: 52
Reputation:
I think this is what you looking for.
SELECT * FROM users
u, albuminfos
ai, albumaccesses
aa WHERE aa.user_id=u.id
Upvotes: 0
Reputation: 1296
I am taking the another table name as albumDetails that holds information for each album based off of the albumID.
select albumAccess.*, albumDetails.* from albumAccess, albumDetails where
albumAccess.albumID=albumDetails.albumID and
albumAccess.userID=YOUR_REQUIRED_USER_ID
Upvotes: 0
Reputation: 7244
Its hard without a syntax to work with but i think something like this could work.
SELECT
tablea.*,
tableb.*
FROM albumaccess tablea
JOIN albuminfo tableb ON tablea.AlbumId=tableb.AlbumId
WHERE tablea.UserId='theuserid'
This will JOIN rows matching on AlbumId.
Upvotes: 1