View Single Post

   
  #3 (permalink)  
Old 04-08-2008, 09:20 AM
grohrer@gmail.com
 
Posts: n/a
Default Re: Please help me with a simple query!!!

I DO know the widgets I want to return, for example

Dept Product
01 002312
02 023124
01 002315
05 002312
....

As you can see, there are two product numbers with 002312 but each has
a different department. In all I have a hundred or more KNOWN widgets
that I want to return.

My question is how can I build an effecient query against a table when
I have about a hundred or so items like the above, where I need to
query against the department number AND product number.

Do I do the long where clause for about a hundred of these..
...
WHERE (dept = '01' AND product = '002312) OR (dept = '02' AND product =
'023124') OR...

Or is there a better way? The above example will make for a REALLY
long query string.

Thanks,


stephen O'D wrote:
> grohrer@gmail.com wrote:
> > I have a table which contains information regarding widgets. Each
> > widget has a Department Number and a Product Number.
> >
> > I need to query the table for a specific set of widgets...about 100 in
> > all.
> >
> > I'm familiar with the basic queries such as:
> >
> > SELECT *
> > FROM projectTable
> > WHERE prodNum IN ('002312','023124','254124')
> >
> > which works great if your only querying with a single specific field.
> >
> > The only other method I know if is to do the following:
> >
> > SELECT *
> > FROM projectTable
> > WHERE (deptNum = '01' AND prodNum = '002312') OR (deptNum = '02' AND
> > prodNum = '002314') OR .......
> >
> > Using this method for a hundred widgets would make for a pretty sizable
> > query string.
> >
> > Is there another method which is better and effecient?
> >
> > Thanks in Advance!

>
> How do you know what digits you want to get? You must have some way of
> identifying the set of widgets that you need to extract to find the
> values to put in the where clause ...


Reply With Quote