Retrieve multiple values from table, bit value and ID

I would like to retrieve all data related to a spesific ID and also all of those data that have a bit value of 1 within the same table.

This is the table data:

Description
--------------------- 
INT        DID
INT        DescID             
VARCH      DescTitle
VARCH      DescText
BIT        ForAll

Description_Join
---------------------
INT        DJID
INT        DescID
INT        ProductID

The tables are joined by the DescID. So now I would like to show all data with a specific ProductID (from request.querystring) and i will also like to display ALL data from the table “description” where the field “ForAll” has the BIT value of 1.

I just cannot get this to work.

This is the Sql I have tried

SELECT D.DescID, DJ.DescID, DJ.ProductID, D.ForAll, D.DescTitle, D.DescText 
FROM Brand_Variant_Description D
INNER JOIN Description_Join DJ ON (D.DescID = DJ.DescID)
WHERE DJ.ProductID=222 AND D.BrandDescAllSel=1


Source: sql

Leave a Reply