By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

If statement in Access query

P: 1
Hi,

I tried searching for this answer but I'm not even sure what to look for. I'll do my best to explain.

I'm trying to create a query in Access. I have multiple WHERE conditions and depending on which WHERE condition returns true I want to return data froma specific column in the table.

My database has columns named Date1, Time1, Option1, Date2, Time2, Option2, Date3, Time3, Option3, etc..

What I have so far:

SELECT columnname
FROM Table
WHERE Date1 = [@date] OR Date2 = [@date] OR Date3 = [@date]

Now how do I have it return only the corresponding Time and Option column without returning them all.

I guess I have to use some kind of IF satement but I don't have a clue as to the syntax.

Thanks
Sep 26 '06 #1
Share this Question
Share on Google+
1 Reply


PEB
Expert 100+
P: 1,418
PEB
So you need sth like this?

SELECT columnname, SWITCH(Date1 = [@date], columnname1, Date2 = [@date] , columnname2, Date3 = [@date], columnname3) AS Wanted_date
FROM Table;


:)
Sep 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.