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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get 3rd field from 2 previous 2 fields in Query

Status
Not open for further replies.

ping99

Technical User
Mar 16, 2006
45
CA
Hi all,

I have mytable with 2 fields ( Name1 and Name2 ) and want to get Newtable or newQuery
with 1 field called Name3:

blank and blank2 are fixed.

if Name1 = blank then Name3 must = ccccc

if Name1 = aaaaa then Name3 must = aaaaa

if Name1 = blank then Name3 must = blank and not blank2

...............


mytable

Name1: Name2:

aaaaa bbbbb
blank ccccc
blank blank2
ddddd eeeee
fffff ggggg
blank hhhhh

Newtable

Name3:

aaaaa
ccccc
blank
ddddd
fffff
hhhhh
How to do this with SQL ?

TIA
 
Something like this ?
SELECT IIf(Name2='blank2',Name1,IIf(Name1='blank',Name2,Name1)) AS Name3
INTO Newtable
FROM mytable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you PHV,

It worked great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top