sql - Using IN with multiple columns -


just quick question. i'm using single values manually inputed user , doing sql query comparing 2 columns, like:

select col3,col1,col4 table col1='somereallylongtext' or col2='somereallylongtext' 

the repetition of somereallylongtext tolerable, program supports looping through excel document several hundred rows - means i'll doing:

select col3,col1,col4 table col1 in('item1','item2',...'itemn') or col2 in('item1','item2',...'itemn') 

and query exhaustively long, can't imagine efficient. is there way shorten this 2 columns can compared same in(xxx) set?

if not, there other (more efficient) ways of giving set of values in query?

(i'm using c# .net 4.0 client profile, using excel interop access file)

i'm not sure performance you'd this:

select col3,col1,col4 table exists (     select 1     (values         ('item1')         , ('item2')         , ...         , ('itemn')     ) it(m)     it.m in (col1, col2, ...) )    

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -