This is a discussion on DTS Excel Import, Transform - how do I use "OR" clause in SQL Query within the SQL Server forums, part of the Microsoft SQL Server category; --> Howdy. I'm trying to build a query that will take an Excel file and pull a few rows of ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Howdy. I'm trying to build a query that will take an Excel file and pull a few rows of data from a particular sheet. I'm having a problem with my WHERE clause - I can can tell it to import WHERE a field matches a value, or WHERE the field matches another value, but not both. I've tried bunches of different variations, but can't get it to work. Is there any way to do this? Works: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where ((F1 = 'Body')) Works: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where F1 = 'Cash' Doesn't: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where F1 = 'Body' OR F1 = 'Cash' Doesn't: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where (F1 = 'Body' OR F1 = 'Cash') Doesn't: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where ((F1 = 'Body') OR (F1 = 'Cash')) |
| ||||
| Did you try: select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where F1 = 'Body' union all select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where F1 = 'Cash' or select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 from `RAF082604$` where F1 in ( 'Body', 'Cash') "Michael Bourgon" <bourgon@gmail.com> wrote in message news:558b578d.0409010509.1f10c665@posting.google.c om... > Howdy. I'm trying to build a query that will take an Excel file and > pull a few rows of data from a particular sheet. I'm having a problem > with my WHERE clause - I can can tell it to import WHERE a field > matches a value, or WHERE the field matches another value, but not > both. > I've tried bunches of different variations, but can't get it to work. > Is there any way to do this? > > Works: > select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 > from `RAF082604$` > where ((F1 = 'Body')) > > Works: > select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 > from `RAF082604$` > where F1 = 'Cash' > > Doesn't: > select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 > from `RAF082604$` > where F1 = 'Body' OR F1 = 'Cash' > > Doesn't: > select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 > from `RAF082604$` > where (F1 = 'Body' OR F1 = 'Cash') > > Doesn't: > select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 > from `RAF082604$` > where ((F1 = 'Body') OR (F1 = 'Cash')) |
| Thread Tools | |
| Display Modes | |
|
|