If I understand you correctly, you already have the first part of your set of data from this statement:
So, I need to combine 3 tables just to get the proper UserId and ProductId information, and then I need to take the ProductId and see if it is in the ProductReviews table where UserId = ReviewerProfileId.
To combine the two, here's one way of doing it in SQL Server (you didn't mention what flavor of SQL you are using):
;WITH UserProducts AS (
SELECT [ProductId], [UserId]
FROM [Orders]
INNER JOIN [OrderItems] ON UserId= [current user id]
WHERE [ProductId] = [whatever the current product id is])
OR [ProductId] IN
(SELECT [uidProduct]
FROM [ApprovedProductReviews]
WHERE [uidProduct]= [current user id])
)
SELECT
P.*
FROM ProductReviews P
WHERE NOT EXISTS(
SELECT *
FROM UserProducts UP
WHERE UP.ProductId = P.ProductId AND UP.UserId = P.ReviewerProfileId
)
This starts with what you already have: the user's list of products ordered as a common table expression (CTE), and then uses that to find entries in ProductReviews
that don't have a corresponding hit.
If you aren't using a version of SQL that supports CTE's, then you could put your whole existing query inside the WHERE NOT EXISTS
block, or use that to fill a temporary table (or table variable).