using Left function to take first 5 character from a access field

i have a text field named 'zip' in an access database that contains a zipcode such as "60101-0452".
the user enters a 5 digit zipcode in a form (i.e Form.password)
i want to be able to compare the first 5 digits of the 'zip' field to what the user entered.


<cfquery name="qname" datasource="dsname">
      
      SELECT * FROM table where username = '#Form.username#' AND zip = '#Form.password#'
      
</cfquery>
Judy DeoAsked:
Who is Participating?
 
Chandramouli kArchitectCommented:
try this.

select * .... and left(zip,5) = '#Trim(FORM.Password)#'
0
 
bwasyliukCommented:
How about...

<cfquery name="qname" datasource="dsname">
     
     SELECT * FROM table where username = '#Form.username#' AND LEFT(zip,5) = '#Form.password#'
     
</cfquery>

I use MSSQL server, and did a sample query like this, and from a quick check I assume Access allows the same thing.

Here is my sample: select * from employee where left(lastname,2) = 'An'
Matches Anderson, Andrews, Anthony and so on.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.