Tutorial :ms-access: proper syntax for a long condition statement



Question:

here's my condition:

([Panels] like '*something*' or [Panels] like '*something1*') AND ([Panels] like '*something2*' or [Panels] like '*something3*')  

another words, here is the logic:

[Panels] has to be one of the following (IT_AMPH | AMPH_SN | AMPH_S) AND it has to be one of the following: (IT_BARB | BARB_SN | BARB_S)


Solution:1

Try using In

[Panels] In ('IT_AMPH','AMPH_SN ','AMPH_S')  AND [Panels] In ('IT_BARB','BARB_SN','BARB_S')  

This will return True if [Panels] is in both lists.

If you want to use exclusively and and or... well, it can be a real headache:

([Panels]='IT_AMPH' AND [Panels]='AMPH_SN ' AND [Panels]='AMPH_S')  OR ([Panels]='IT_BARB' AND [Panels]='BARB_SN' AND [Panels]='BARB_S')  

Hope this helps you.


If you need to use wildcards, you can replace the = with Like:

([Panels] Like '*IT_AMPH*' AND [Panels] Like '*AMPH_SN*' AND [Panels] Like '*AMPH_S*')  OR ([Panels] Like '*IT_BARB*' AND [Panels] Like '*BARB_SN*' AND [Panels] Like '*BARB_S*')  

Hope this helps you.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »