mulitple query criteria

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
I'm trying to write a query and use mulitple criteria for two different fields?

Example fields and criteria:

Department Department
Like "a*" or Like "b*" Like "901" or Like "902"

I'm only getting the vendors that start with a or b. I'm only getting the vendors starting with a or b and I'm not getting departments 901 or 902. I get all departments for a or b.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Can you post the SQL? If you don't know how to see the SQL, open your query in Design View, then go to View-SQL View.

Thank you,

Russell
 
Upvote 0
SELECT t_AI_Survey.dept, t_AI_Survey.[Vendor #], t_AI_Survey.[Vendor Name], t_AI_Survey.[ID on Flow Strategy], t_AI_Survey.[Initial Meeting], t_AI_Survey.[AI Capacity/Capability], t_AI_Survey.[Handle Multi Packing], t_AI_Survey.[Doing AI with any other retailers], t_AI_Survey.[Target AI Vendor], t_AI_Survey.[Create Master UPC], t_AI_Survey.[850 with Subline Level], t_AI_Survey.[856 and 810 Master UPC], t_AI_Survey.[810 at carton level], t_AI_Survey.[Carton Labeling], t_AI_Survey.[Add'l Costs], t_AI_Survey.[Add't Cost Amt], t_AI_Survey.[Pack Req], t_AI_Survey.[AI Cand], t_AI_Survey.[Duplicate Dept], t_AI_Survey.[Class/Subclass], t_AI_Survey.[Program Description], t_AI_Survey.[Month of Roll Out], t_AI_Survey.ETA, t_AI_Survey.[EDI test order #], t_AI_Survey.[asst item order #], t_AI_Survey.[Valid ASN], t_AI_Survey.[Valid UCC-128], t_AI_Survey.[EDI Capable], t_AI_Survey.[DC Notes Updated (1st ship only)], t_AI_Survey.[Check Sample Test- Pass], t_AI_Survey.[Check Sample Test - Fail], t_AI_Survey.Comments, t_AI_Survey.[Merchant Contact], t_AI_Survey.[Merchant Contact Ext #], t_AI_Survey.[EDI Contact], t_AI_Survey.[EDI Contact Tel#], t_AI_Survey.[EDI ext], t_AI_Survey.[EDI Contact EMAIL], t_AI_Survey.[Sales Contact], t_AI_Survey.[Sales Contact Tel#], t_AI_Survey.[Sales ext], t_AI_Survey.[Sales Contact EMAIL], t_AI_Survey.[Operations Contact], t_AI_Survey.[Operations Tel#], t_AI_Survey.[Operations ext], t_AI_Survey.[Operations EMAIL]
FROM t_AI_Survey
WHERE (((t_AI_Survey.dept)=953 Or (t_AI_Survey.dept)=954 Or (t_AI_Survey.dept)=956 Or (t_AI_Survey.dept)=943 Or (t_AI_Survey.dept)=944 Or (t_AI_Survey.dept)=948 Or (t_AI_Survey.dept)=990 Or (t_AI_Survey.dept)=951 Or (t_AI_Survey.dept)=989 Or (t_AI_Survey.dept)=991 Or (t_AI_Survey.dept)=992 Or (t_AI_Survey.dept)=949 Or (t_AI_Survey.dept)=950 Or (t_AI_Survey.dept)=901 Or (t_AI_Survey.dept)=903 Or (t_AI_Survey.dept)=904 Or (t_AI_Survey.dept)=905) AND ((t_AI_Survey.[Vendor Name]) Like "i*")) OR (((t_AI_Survey.[Vendor Name]) Like "j*")) OR (((t_AI_Survey.[Vendor Name]) Like "k*")) OR (((t_AI_Survey.[Vendor Name]) Like "l*")) OR (((t_AI_Survey.[Vendor Name]) Like "m*")) OR (((t_AI_Survey.[Vendor Name]) Like "n*")) OR (((t_AI_Survey.[Vendor Name]) Like "o*"));
 
Upvote 0
Change your criteria to be something like this:
  • WHERE (((t_AI_Survey.dept) In (903,904,905))) OR (((Left([Vendor Name],1)) In ("i","j","k","l","m","n","o","p")));
The way you have it now, there are some AND conditions that you probably don't want.

HTH,

Russell
 
Upvote 0

Forum statistics

Threads
1,221,545
Messages
6,160,446
Members
451,646
Latest member
mmix803

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top