Mulitple OR conditions in SQL


2008-02-26 Digg! icurtain Delcious icurtain

based on

ORDER_TRANSACTION
__________
1|ORDER__|
2|CREDIT__|
3|REFUND_|
4|PAYMENT|

Instead of the following:

SELECT
ot
FROM
OrderTransaction
AS
ot
WHERE
ot.transactionType.transactionTypeDesc = 'Credit'
OR
ot.transactionType.transactionTypeDesc = 'Refund'
OR
ot.transactionType.transactionTypeDesc = 'Payment'

you could use:

SELECT
ot
FROM
OrderTransaction
AS
ot
WHERE
ot.transactionType.transactionTypeDesc IN ('Credit','Refund','Payment')

or:

SELECT
ot
FROM
OrderTransaction
AS
ot
WHERE
ot.transactionType.transactionTypeDesc NOT IN ('Order')