SQL Question: Multiple Criteria in WHERE statement

bacon333

Senior member
Mar 12, 2003
524
0
0
Here's my sql string:
strSQL = "SELECT yield FROM 5000records WHERE partnum = 9594 AND line = STD OR line = HS1 OR line = HS2

I'm trying to grab all yield values from table 5000records where the part number is 9594 and the line is STD or HS1 or HS2. The above string selects ALL of the HS1 and HS2 even when the part number isn't 9594. Any ideas?
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Like algebra, sometimes SQL requires parentheses.

Try:

SELECT yield FROM 5000records WHERE partnum = 9594 AND (line = STD or line = HS1 or line = HS2)

Even better:

SELECT yield FROM 5000records WHERE partnum = 9594 AND line IN (STD, HS1, HS2)