Q
Problem solve Get help with specific problems with your technologies, process and projects.

Search for a value in 12 columns

I am currently building an Access database. One of the tables contains an employee name and then 12 columns, which each hold a date value. I would like to query all 12 fields at once to look for one date and then pull that record if the date is contained in one of them.

I am currently building an Access database for booking and invoicing at the small business where I work. One of...

the tables I have built contains an employee name and then a number of columns which range from Popup_Date_1 to Popup_Date_12, which each hold a date value.

I would like to query all 12 fields at one time to look for one date and then pull that record if the date is contained in one of the twelve fields, but I am not able to get Microsoft Access to do this.

Is there an SQL query I could use to accomplish this? I'm sorry to be a bit more ignorant than most people on this site. This is the last obstacle to getting the whole thing working so I would love any advice you could offer!

First of all, here is the query that you need:

select employee_name
     , Popup_Date_1 
     , Popup_Date_2 
     , Popup_Date_3 
     , Popup_Date_4 
     , Popup_Date_5 
     , Popup_Date_6 
     , Popup_Date_7 
     , Popup_Date_8 
     , Popup_Date_9 
     , Popup_Date_10
     , Popup_Date_11
     , Popup_Date_12
  from bookings
 where Popup_Date_1 = [enter search date]
    or Popup_Date_2 = [enter search date]
    or Popup_Date_3 = [enter search date]
    or Popup_Date_4 = [enter search date]
    or Popup_Date_5 = [enter search date]
    or Popup_Date_6 = [enter search date]
    or Popup_Date_7 = [enter search date]
    or Popup_Date_8 = [enter search date]
    or Popup_Date_9 = [enter search date]
    or Popup_Date_10 = [enter search date]
    or Popup_Date_11 = [enter search date]
    or Popup_Date_12 = [enter search date]

But more importantly—and thank you for asking for advice—your table should probably be normalized. Do a web search for the terms "database normalization" and "first normal form." You will find many useful articles.

This was last published in January 2007

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close