Criteria in more than 1 column

unc2plo

Board Regular
Joined
Mar 18, 2002
Messages
148
I want to query against a table of items based on certain columns having an "x" in them.

The list of items has 3 columns that could have an "x" or letter in 1 or 2 of them. I want to be able top say show me any item that has an "x" or letter in any column.

So far I can get it to show me only 1 column using Like "x" in the criteria, but I can only see one at a column at a time.

Is there a way to say - If any of these columns has anything in it show that row? I made a mini version of teh table belwo. I couldn't get the upload tool to work on my PC. I want to see all rows except the last since it doesn't have a mark in any of the 3 columns.

Make sense?

Thanks,
David

Col 1 Col 2 Col 3 Item # Description
x 9971 Item 1
x x 2906 Item 2
x 4304 Item 3
A 8833 Item 4
4455 Item 5
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
OK, my table replication didn't work.

Anyway, all it is is columns 1 - 3 which could be marked with an "x" or letter, and an item number and description. I want to see any item that is marked, but not those that have no marks in any column.

Thanks,
David
 
Upvote 0
You need an OR criteria, in the design view of the query criteria placed on the same row act as an AND criteria, criteria placed in separate rows act as OR criteria.
You just need to make sure that you "X" criteria are on separate rows.


The SQL will look something like

SELECT tblMyTable.col1, tblMyTable.col2, tblMyTable.col3, tblMyTable.item, tblMyTable.Description
FROM tblMyTable
WHERE (((tblMyTable.col1)="x")) OR (((tblMyTable.col2)="x")) OR (((tblMyTable.col3)="x"));

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,561
Messages
6,160,495
Members
451,653
Latest member
agata

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