• 2Tall (11/13/2012)


    Hi to all. I haven't posted for a while and it is now time to wear my sql cap again 🙂

    I have a query which in brief has the following filter:

    WHERE ProductId = @ProductId AND StructureVersion = @StructureVersion AND Type IN (@Types)

    AND ISNULL(CVProdFolder.CustomFieldValueBit,'False') = @ProdFolderReq AND ISNULL(CVProdAidDoc.CustomFieldValueBit,'False') = @ProdAidDoc

    The bit I am interested in is:

    AND ISNULL(CVProdFolder.CustomFieldValueBit,'False') = @ProdFolderReq AND ISNULL(CVProdAidDoc.CustomFieldValueBit,'False') = @ProdAidDoc

    The filter currenty returns 1 row as both @ProdFolderReq and @ProdAidDoc = 1

    I would like to return 1 record if either or both return 1 (i.e. drop the AND). I tried OR but this returns multiple records.

    Can this be done?

    Kind Regards,

    Phil.

    1st. What you are expecting to have in @Types? Is it comma separated string? If yes, then your "Type IN (@Types)" filter will never work as it is absolutely the same as "Type = @Types"

    2nd. You should really show what you have tried with OR.

    But I guess it should be like that :

    AND

    ( ISNULL(CVProdFolder.CustomFieldValueBit,'False') = @ProdFolderReq

    OR ISNULL(CVProdAidDoc.CustomFieldValueBit,'False') = @ProdAidDoc )

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]