简体   繁体   中英

Passing a set of value to a WHERE clause without using IN Operator

I have this Query

SELECT 
    ID, isDebit, AccountID, SUM(Amount) AS Amount
FROM
    journaltransactions
WHERE
    AccountID IN (45,23,78,90,37,48)

Any one have idea to solve the same without using IN Operator .

Is it possible to iterate through this set of value in Procedure or something

I have no idea to solve this without IN Operator

Any help will be appreciatable

Although I do not particularly understand the requirement for not using in operator, it can be achieved through a series of or :

SELECT 
    ID, isDebit, AccountID, SUM(Amount) AS Amount
FROM
    journaltransactions
WHERE
    AccountID = 45 OR
    AccountID = 23 OR
    AccountID = 78 OR
    AccountID = 90 OR
    AccountID = 37 OR
    AccountID = 48

Pls note that this query may be slower than the one using in .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM