How do I...

R

rms

How do I create a query to check for a string value in one field in another
string field? For example, assume the following table...

ID String1 String2
1 abc ab
2 abc bc
3 xyz a


What I want to do... is create a query that would validate whether or not
the data in String2 exists in String1. Something like this:

ID String1 String2 Valid
1 abc ab True
2 abc bc True
3 xyz a False

I tried using the strcomp and instr functions but keep getting an error.
Any help would be greatly appreciated!

Sincerely,

Rob
 
D

Dirk Goldgar

rms said:
How do I create a query to check for a string value in one field in
another string field? For example, assume the following table...

ID String1 String2
1 abc ab
2 abc bc
3 xyz a


What I want to do... is create a query that would validate whether or
not the data in String2 exists in String1. Something like this:

ID String1 String2 Valid
1 abc ab True
2 abc bc True
3 xyz a False

I tried using the strcomp and instr functions but keep getting an
error. Any help would be greatly appreciated!

Sincerely,

Rob

Try this model SQL, substituting the correct field and table names:

SELECT
ID, String1, String2,
(String1 Like '*' & String2 & '*') As Valid
FROM YourTable;
 
L

Lemark23

Dirk's is good. Here is another model that may be more apparent to a
beginner in Access. Perhaps not.

Go to the query designer. select your string1 and your string two bry
dragging them into the designer. use an iif statement to compare the
values. you can look up the syntax on microsoft.com.

That will give you the columns you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top