Query / Count Length Of Field

C

carl

I have data like this...


Symbol Codes
GES ABCIPXZ
TMO BCPX
A ABCIPQWXZ
AA ABCIPQWXZ
AAI ABCIPXZ


The "codes" field can be 1 to 9 characters. Is it possible for a query
to return Symbol when Codes contains a "B" and the length of the field
is 4 characters or less ?

Thank you in advance.
 
B

Bob Barrows

carl said:
I have data like this...


Symbol Codes
GES ABCIPXZ
TMO BCPX
A ABCIPQWXZ
AA ABCIPQWXZ
AAI ABCIPXZ


The "codes" field can be 1 to 9 characters. Is it possible for a query
to return Symbol when Codes contains a "B" and the length of the field
is 4 characters or less ?

Thank you in advance.

You didn't tell us what you wanted it to return if the conditions weren't
met ...

SELECT
iif([Codes] LIKE '*B*' AND len([Codes]) <= 4, [Symbol],<fill in the default
value you want>) AS YourFieldName
FROM Tablename

Or maybe you only want it to return rows where those conditions are met ...
?

SELECT [Symbol] AS YourDesiredFieldName
FROM Tablename
WHERE [Codes] LIKE '*B*' AND len([Codes]) < 4
 

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