2 Replies Latest reply: Jul 30, 2013 5:48 AM by Jonathan Dienst RSS

    Select with multiple 'WHERE' 'AND' conditions

      Hello,

       

      I am trying to select records with a number of conditions.

      However, it seems like the SQL statement ignores the extra OR's. Is there another way to make this selection?

      The database includes more than 30 types of smov2_action so excluding is no option.

        • Re: Select with multiple 'WHERE' 'AND' conditions
          Kabilan Kumarasamy

          try below

           

          LOAD

                    smov2_part                         as [Part],

                    smovqty                              as [Value],

                    date(smov2_date)               as [Date];

          SQL SELECT

              smov1_rec_type,

              smov2_action,

              smov2_part,

              smov2_date,

              smovqty

          FROM SMOV_DATA

          WHERE     smov1_co_site = 1

          AND          (smov2_action = 'UPLISS'

          OR            smov2_action = 'UPLREC'

          OR            smov2_action = 'SALISS'

          OR            smov2_action = 'WIPISS'

          OR            smov2_action = 'WIPREC'

          OR            smov2_action = 'WIPRRV'

          OR            smov2_action = 'NILSTK');

          • Re: Select with multiple 'WHERE' 'AND' conditions
            Jonathan Dienst

            Hi

             

            I would do it like this:

             

            [StockMovements]:
            LOAD
                smov2_part as [Part],
                smovqty as [Value],
                date(smov2_date) as [Date]
            ;
            SQL SELECT 
                smov2_part,
                smov2_date,
                smovqty
            FROM SMOV_DATA
            WHERE smov1_co_site = 1
            AND smov2_action IN ('UPLISS', 'UPLREC', 'SALISS', 'WIPISS', 'WIPREC', 'WIPRRV', 'NILSTK')
            ;
            

             

            No need to SELECT items not used in the load.

             

            Hope that helps

            Jonathan