MS access query - change values in result set using if statements, etc.

Hello,

I would like to create a make table query in access.    Before populating the results in the table, I want to change values in the results for one of the columns using "IF" statements.

e.g. If value = "XXX" then
            change value to "YYY"

Should I put the If statements in the SQL statement?  

How do I change the values?

Thanks for your help.

SELECT X, Y, Z
FROM [tbl1] INNER JOIN [tbl2] ON [tbl1].[Customer Account Number] = [tbl2].AccountNumber
WHERE ((([tbl1].[Customer Account Create Date]) Between "20110901" And "20111001"));

Open in new window

lchaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
use the IIF function , IIf(expr, truepart, falsepart)

SELECT X, Y, Z, IIf([fieldName]="xxx","yyy",[fieldName]) as Z
From ....
0
lchaAuthor Commented:
thanks so much for your resoponse capricorn1

To clarify I need, I am actually looking for 3 different values in the column results and need to change those values to more something more understandable to the

Will the IIF function allow me to do what I need because it is limited to returning 2 different values right?

iif ([Qty] > 10, "large", "small")

Thanks!
lcha

0
Rey Obrero (Capricorn1)Commented:
post the conditions
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lchaAuthor Commented:
sorry that this isn't obvious to me ... can you give an example

I need to check for 3 different values in the column results and change the values for all of them.
iif ([fieldname1]="xxx", "yyy")
iif ([fieldname1]="abc", "xxx")
iif ([fieldname1]="def", "zzz")



0
Rey Obrero (Capricorn1)Commented:

iif ([fieldname1]="xxx", "yyy", iif ([fieldname1]="abc", "xxx",iif ([fieldname1]="def", "zzz",[fieldname1])))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThomasianCommented:
Alternatively, you can use the SWITCH function which allows multiple conditions.

i.e.
SWITCH([fieldname1]="xxx", "yyy", [fieldname1]="abc", "xxx", [fieldname1]="def", "zzz")

Open in new window

0
lchaAuthor Commented:
that worked, thank you! :)
0
lchaAuthor Commented:
thanks Thomasian, I will look into your solution as well later.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.