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

String query

P: n/a
I'm trying to compare two fields in a table. If the whole of the first field
is found somewhere within the second field, I need to output the second
field into a third field..

e.g.

Field1 = abcd

Field2 = xyzabcdefg

Since Field1 is found within Field2, Field3 =xyzabcdefg

I 'm able to do this if the wholecontents of Field1 exactly matches the
whole contents of Field2, viz - Field3: IIF([Field1] = [Field2],[Field2],"")

However, I can't get this expression to recognise when Field1 matches only
part of Field2.

Regards

Bernadette

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
[Field3] =IIf(Instr([Field2],[Field1)>0,[Field2],"")

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Bernadette Houghton" <bh*******@ozemail.com.au> wrote in message
news:eV*****************@nnrp1.ozemail.com.au...
I'm trying to compare two fields in a table. If the whole of the first field is found somewhere within the second field, I need to output the second
field into a third field..

e.g.

Field1 = abcd

Field2 = xyzabcdefg

Since Field1 is found within Field2, Field3 =xyzabcdefg

I 'm able to do this if the wholecontents of Field1 exactly matches the
whole contents of Field2, viz - Field3: IIF([Field1] = [Field2],[Field2],"")
However, I can't get this expression to recognise when Field1 matches only
part of Field2.

Regards

Bernadette

Nov 12 '05 #2

P: n/a
"Bernadette Houghton" <bh*******@ozemail.com.au> wrote in message
news:eV*****************@nnrp1.ozemail.com.au...
I'm trying to compare two fields in a table. If the whole of the first field is found somewhere within the second field, I need to output the second
field into a third field..

e.g.

Field1 = abcd

Field2 = xyzabcdefg

Since Field1 is found within Field2, Field3 =xyzabcdefg

I 'm able to do this if the wholecontents of Field1 exactly matches the
whole contents of Field2, viz - Field3: IIF([Field1] = [Field2],[Field2],"")
However, I can't get this expression to recognise when Field1 matches only
part of Field2.

Regards

Bernadette


Try the following query:

UPDATE Table1 SET Field3 = Field2 WHERE Field2 Like '*' & Field1 & '*';
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.