Getting results from two tables

I have two tables that basically look like this…

Items
ItemID
UserID
Title

SharedItems
SharedItemID
ItemID
UserID

Items holds a table of items and who owns it (UserID) and SharedItems says what item (ItemID) is shared with whom (UserID).

I’m wanting a query that pulls any items that the user owns (from Items) and which items are shared with the user.

Every query I’m trying either pulls records from one or the other but not both. Here’s an example and I know I’m just missing something simple. It’s been a while since I’ve written queries.

SELECT Items.* FROM Items INNER JOIN SharedItems ON Items.ItemID = SharedItems.ItemID WHERE SharedItems.UserID = 69 OR Items.UserID = 69

This is only grabbing the shared items though, not the items they own and the shared items.

Any ideas? Thanks!

SELECT Items.* FROM Items WHERE Items.UserID = 69 UNION SELECT Items.* FROM SharedItems INNER JOIN Items ON Items.ItemID = SharedItems.ItemID WHERE SharedItems.UserID = 69

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.