Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query - Same Criteria, Multiple Columns

Status
Not open for further replies.

forrest33

ISP
Sep 25, 2003
25
CA
Here's my dilemma:

Company Code1 Code2 Code3 Code4 Code5 Code6

How do i search for, let's say code 417230 through all the 6 code columns? Or do I need to reconfigure my table?
 
Or do I need to reconfigure my table
Have a look here:

Anyway, you may consider a normalization query, say qryCodeNorm:
SELECT Company, 'Code1' AS CodeCol, Code1 AS Code
FROM yourTable WHERE Code1 Is Not Null
UNION ALL SELECT Company, 'Code2', Code2
FROM yourTable WHERE Code2 Is Not Null
...
UNION ALL SELECT Company, 'Code6', Code6
FROM yourTable WHERE Code6 Is Not Null

And now your search query:
SELECT * FROM qryCodeNorm WHERE Code = 417230

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top