Lupi
Lupi

Reputation: 33

Query And/Or Value

I am putting together a query in order to look at a record (a load number) and look at five different variables, separated by an OR. So I have the field for the record (load number) - EQ - Value (the load number), AND - Field (for what I want it to look for) - EQ - Value I want it to find. I then have an OR, set it up with an AND for the next variable, and repeat this for a total of five times/four OR's.

The results return exactly as I want them to, so the query as is works. What I would like to do is simplify it for the user as in its current form they would need to manually update the value for the load five different times. So basically I am looking for a way for them to update the value on the first line of the query and then for each OR have it reference back to that. Is there any way to do this? Or are they going to just have to do it manually?

ETA-

AND/OR  Field            Test   Value
       T03.BMALCD        EQ     'C3939'
AND    T02.C7A6SH        EQ     'Y'    
OR     T03.BMALCD        EQ     'C3939'
AND    T01.A3VVST        NLIST  'N' 'B'
OR     T03.BMALCD        EQ     'C3939'
AND    T01.A3V1ST        NLIST  'N' 'H'
OR     T03.BMALCD        EQ     'C3939'          
AND    T01.A3LPCE        LIST   '000254' '000310'
OR     T03.BMALCD        EQ     'C3939'          
AND    T01.A3NLST        EQ     'Y'     

So what I would like is that the user doesn't have to enter the value, in this case C3939, multiple times every time they need to look at a different load. To simplify I would like if they just had to update the first value and then have the query reference this for all of the OR's

Upvotes: 1

Views: 80

Answers (1)

Richard Evans
Richard Evans

Reputation: 384

I'd suggest a simple program with a prompt and parm for the SQL statement, but them I'm a programmer (not intended to be sarcastic)

Upvotes: 1

Related Questions