所以我对SQL还不那么熟悉,对于下面的问题,您将看到我缺乏很多知识,但是我需要以下方面的帮助:
我有一个产品,我将其称为ParentProduct;
它包含子产品-ChildProduct1,ChildProduct2等。
我需要查询,该查询将在我的数据库中调出所有具有ChildProducts(不需要返回这些结果)的ParentProducts,这些列在ColumnPosted列中为TRUE。
主要问题之一是我不知道我应该使用的表,因为我没有访问数据库的权限,但是我需要知道我是否在做正确的逻辑。
我有以下内容(出于安全考虑,某些值可能会更改):
WHERE 1=1
AND Product.ClientID=1
AND dbo.Products.ProductID IS NOT NULL -- to show the ParentProduct
AND Products.Status=1 -- to show active products
AND dbo.Products.ProductID IN (SELECT ChildProductID FROM Products WHERE
ColumnPosted = "TRUE") -- Here should be the filter checking if the
--ParentProduct has ChildProducts which are ColumnPosted = True)