Help with Boolean check box combinations

  • Aren't checkbox values either 1 0r 0?

  • If I'm understanding this could this be done in the WHERE clause with a bunch of OR conditions.

    select * 
    From Master as pom
    WHERE Pom.UserID = @userid
    AND ((@Incomplete_Requisition = 1 AND Pom.Status = 0)
    OR (@Submitted_Requisition = 1 AND Pom.Status = 2)
    OR (@Fully_Approved_Requisition = 1 AND Pom.Status = 4)
    OR (@Future_Fully_Approve_Requisition = 1 AND Pom.Status = 94)
    OR (@Future_Cycle_PO = 1 AND Pom.Status IN (95,98))
    OR (@Current_Cycle_PO = 1 AND Pom.Status IN (5,6,7,8))
    OR (@Cancelled_Closed_PO = 1 AND pom.Status IN (100,110)));

    Alternately, you could declare a temporary table, insert statuses based on checkbox values, and then join to the physical table.

    declare @pom        table(status_val        int unique not null);

    if @Incomplete_Requisition = 1
    insert @pom(status_val) values (0);
    if @Submitted_Requisition = 1
    insert @pom(status_val) values (2);
    if @Fully_Approved_Requisition = 1
    insert @pom(status_val) values (4);
    if @Future_Fully_Approve_Requisition = 1
    insert @pom(status_val) values (94);
    if @Current_Cycle_PO = 1
    insert @pom(status_val) values (95),(98);
    if @Future_Cycle_PO = 1
    insert @pom(status_val) values (5),(6),(7),(8);
    if @Cancelled_Closed_PO = 1
    insert @pom(status_val) values (100),(110);

    Select *
    From Master pom
    join @pom p on pom.Status=p.status_val
    WHERE Pom.UserID = @userid;

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Thank you really appreciate the response. it work great, and I see where I was over thinking the WHERE Clause..

Viewing 3 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply