sql - Perform a Union as well as a NOT IN/NOT EXISTS -


I am trying to return all the products to the products that the current user has purchased until they review the product Are not in the table.

Now, there is an order table, which contains all orders and contains UserID.

There is an order item table in which all the orders ordered for each order (based on order ID), as well as ProductId for each item are also included.

However, there is another table to check orders made out of the store website (this table is called approved Representative and has a User ID field and a Product ID field).

Finally, there is a review table of products that contains all submitted reviews for all products (and include reviewer profile ID (which is similar to user ID) and product ID

So far, I have been to see if the current user has purchased a particular product with success:

  SELECT [ProductId] , [UserId] FROM [ORDERS] UserId = at [OrderItems] [current user ID [WHERE [Product ID] = [existing product ID] or [producer] IN (SELECT [uidProduct] FROM [approved productive review] Where [UID Product] = [Current User ID])  

But I'm not sure the productive review product table How can I change this code to check the product available in. I suspect that I may have to make a union but I am not sure ... any help would be appreciated!

For some more clarification, I need to look at the Product Review table ProductId and ReviewerProfileId (which is similar to User ID), basically, the reviewer profile file = UserID). I need to check to see if the Reviewer Profile ID matches the current user ID, then I need to go through the order table to get the User ID, as well as order to receive ProductId Items table, and I must check in the accepted product reviews table as well as UserId and ProductId (this approved productive review Security can be a user's order in the table which was kept out of the site, therefore, they will be counted as it will not appear in the Orders table but still valid orders).

, I need to combine 3 tables to get the proper user ID and product ID information, and then I should get the product ID and it needs to be seen that it is in the review table of the product where UserId = ReviewerProfileId.

Hopefully, that all makes sense.

If I understand you correctly, then you already have your set of data from this statement The first part is:

Therefore, I need to combine only 3 tables to get the proper user ID and product information, and then let me know ProductId and see whether it is in the ProductReviews table. Is where the UserId = ReviewerProfileId.

To combine two, it is a way of doing SQL Server (you have not mentioned the taste of SQL [User Id] as userproducts as userproducts, [UserID] From [Order] Inner Join [Order Items] On User Id = [Existing User ID] Where [Product Id] = [Any existing Product ID]) or [Product ID] (SELECT [uidProduct] FROM [Accepted] Productive review] where [uid product] = [ Current user id]) SELECT P. * product review from where PP is not present (SEL ECT * User Products UP, Product ID = P. Product ID and UP User IP = P. ReviewerProfile ID)

It starts with the one you already have: Entries in the list of users of the products in general table expression (CTE), and then that product review Search Sector has no hit.

If you are not using a version of SQL that supports CTE, then you can enter your full current query inside the WHERE is not present block Or use it to fill the floating table (or table variable) on it.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -