SQL with bunch of or clauses

Jonathan Brotto 420 Reputation points
2024-07-12T14:10:10.2066667+00:00

Trying to get the result with a bunch of or clauses.

SELECT * FROM SA15B WHERE PoNo In (6801398832,6801397033,6801397605,6801393990,6801398301,6801397424,6801398020,6801393991,6801398302,6801397425,6801395049,6801395050,6801394454,6801397707,6801397703,6801395197)

User's image

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,977 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,652 questions
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 45,096 Reputation points
    2024-07-12T14:22:26.8266667+00:00

    Trying to get the result with a bunch of or clauses.

    Read the error message; has nothing to do with the "OR" clause.

    Values are stored as "nvarchar" = string/text, you query it as it would be a numeric; of cause the could fail.

    And "6,801,258,182" is much above the number range for integer = -/+ 2 G.

    Query string as string =>

    SELECT * 
    FROM SA15B 
    WHERE PoNo In ('6801258182');
    
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jonathan Brotto 420 Reputation points
    2024-07-12T14:37:48.5666667+00:00

    Solved with help

    SELECT * FROM SA15B WHERE PoNo IN ('6801398832','6801397033','6801397605','6801393990','6801398301','6801397424','6801398020','6801393991','6801398302','6801397425','6801395049','6801395050','6801394454','6801397707','6801397703','6801395197')


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.