Calico
Calico

Reputation: 416

SQL SELECT WHERE Statement

I am querying some data between two Excel Workbooks. the source sheet has two columns 'Responsible Manager' and 'Responsible Supervisor' that I need to filter on. The filter needs to be the same two names for both, so include rows WHERE

OR

I am struggling with the SQL logic, the string below returns Less rows than expected, suggesting something is incorrect.

"SELECT * FROM [Sheet1$A4:I10000] WHERE (`Responsible Manager`='Name1' OR `Responsible Manager`='Name2') OR (`Responsible Supervisor`='Name1' OR `Responsible Supervisor`='Name2')"

Any help is appreciated Thanks Calico

Upvotes: 0

Views: 373

Answers (1)

braX
braX

Reputation: 11755

You want to use square braces instead of quotes for your field names. Like this:

"SELECT * FROM [Sheet1$A4:I10000] WHERE ([Responsible Manager]='Name1' OR [Responsible Manager]='Name2') OR ([Responsible Supervisor]='Name1' OR [Responsible Supervisor]='Name2')"

Upvotes: 1

Related Questions