Query on part of value

amerifax

Registered User.
Local time
Today, 08:37
Joined
Apr 9, 2007
Messages
304
My field contains very structured data, two characters - three characters.
Example:
13-251
40-251
40-245
66-234
51-233

I want to quarry my table based only on the first two characters. usually I would use several values. In this case, I use two 66 & 51.
13 and 40 and 66

I tried The following with no luck, 66 & 51:

SELECT permit.UPDATE, permit.SEQNO, permit.SEAL, permit.SC
FROM permit
WHERE (((permit.SC)="66")) And (((permit.SC)="51"));

Bob
 
The criteria in my previous post will search for a string at the beginning of your field if you want to search for a string at the end of the field use;

Code:
Like "*66"

and in any position within the field;

Code:
Like "*66*"
 
Last edited:
Also if searching for more than one value you need to use OR not AND

Brian
 
Thanks for taking the time to help me with the issue. It worked well.

I want to add some code that a friend was able to help me with. It does the same but with a different slant:

SELECT permit.SEQNO, permit.SEAL, permit.SC, permit.PER_DATE
FROM permit
WHERE (((permit.PER_DATE)>=#1/1/1989#) AND ((Left([sc],2)) In ("14","20","28","30","40","45","51","59","64","66","67")));

It simplified the code a bit.

Bob
 
That is a different scenario which I'm sure JBB. would have given you if asked the first time around.

Brian
 
I'm sure of that! As I look at my records. He has many times given me excellent help.

It's just that over time, many people look at topics, search. I only wanted to add a piece I came up with. One or two years from now someone might search on "Query on part of a value" and get a solution.

On this very website I was shocked to see how many people viewed one of the topics I listed.

I don't always have the answer, as in never, just a small way to be helpful to site.
Bob
 
Yes it is good to give feedback and your final solution, thanks for that, I now wonder why I posted what I did.

Brian
 

Users who are viewing this thread

Back
Top Bottom