String contains query.

  • Thread starter Thread starter david
  • Start date Start date
D

david

How can I create a query that will search for the existance of a char. field
in a string. I'm using Access 2000.

For example:
The char. field would be 'CEC' and the char. var is 'CHL ABC DEF CEC'

Thanks.
 
In the Criteria row under the char field, enter:
Like "*"CEC*"

It is possible (depending on settings) you need to use % in place of *.
 
Hi David,

If you want to select only those rows where the contents of the char
field are in the string then do this:

SELECT tblSomeTable.CharField
FROM tblSomeTable
WHERE ((("CHL ABC DEF CEC") Like "*" & [CharField] & "*"));

If you want all rows, but want to know if the value of the char field
is in the string then do this:

SELECT OtherFields, CharField, "CHL ABC DEF CEC" Like "*" & [CharField] &
"*" AS FieldInString
FROM tblSomeTable;

The FieldInString will be a boolean values (-1 = true or 0 = false).

Clifford bass
 
Thanks. That's was what I was looking for.
--
david


Clifford Bass said:
Hi David,

If you want to select only those rows where the contents of the char
field are in the string then do this:

SELECT tblSomeTable.CharField
FROM tblSomeTable
WHERE ((("CHL ABC DEF CEC") Like "*" & [CharField] & "*"));

If you want all rows, but want to know if the value of the char field
is in the string then do this:

SELECT OtherFields, CharField, "CHL ABC DEF CEC" Like "*" & [CharField] &
"*" AS FieldInString
FROM tblSomeTable;

The FieldInString will be a boolean values (-1 = true or 0 = false).

Clifford bass

david said:
How can I create a query that will search for the existance of a char. field
in a string. I'm using Access 2000.

For example:
The char. field would be 'CEC' and the char. var is 'CHL ABC DEF CEC'

Thanks.
 
Back
Top