Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hii I am again here with a very simple and stupid question.
I am trying to apply two condition on the data while loading, i used
where division= 10 or division=20
which is working fine but at the same time I have to put condition and where document_type is not equal to 'ABC' and 'DEF'
i tried doing
where division='10' or division='12' and Document_type <> 'ABC' or Document_type <> 'DEF'
will it work
thanks in advance
Often clearer to use brackets as well and force the evaluation order correclt:
where ( division='10' or division='12' ) and ( Document_type <> 'ABC' or Document_type <> 'DEF' )
Or maybe use the Match() function :
where Match (division,'10',12') and not Match (Document_type ,'ABC' ,'DEF')
and can I use multiple Where statements in same script
if yes then how
I am not aware of any reason why you cannot have multiple conditions/fields in your 'where'clause - you may want to use parenthesis to group correctly.
not sure I understand why you want to ahve multiple where clauses in a single select statement
Use
Where (Division = '10' or Division = '12')
and Document <> 'ABC'
and Document <> 'DEF'
Eduardo
Often clearer to use brackets as well and force the evaluation order correclt:
where ( division='10' or division='12' ) and ( Document_type <> 'ABC' or Document_type <> 'DEF' )
Or maybe use the Match() function :
where Match (division,'10',12') and not Match (Document_type ,'ABC' ,'DEF')
Be careful with multiple conditions and the relational operators you use to tie them together. The clause
where division='10' or division='12' and Document_type <> 'ABC' or Document_type <> 'DEF'
will not do what you intend to do, because the combination division='10' and Document_type = 'ABC' will still get loaded. The first and the last parts of your where clause will match...
To be absolutely sure that the correct parts are combined and evaluated in the right order, use parentheses to group conditions. For example, this clause will act according to your description. It isn't that different from your original:
where (( division='10' ) or ( division='12' )) and (Document_type <> 'ABC') AND (Document_type <> 'DEF')
An alternative would be to use the match() function. Makes things a bit easier. For example, the previous WHERE is equal to the following:
where Match(division, '10', '12') and Not Match(Document_type, 'ABC', 'DEF')
Best,
Peter
I got that . Thank you very much.. I really appreciate it.