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

Posted on 2004-11-02
Last Modified: 2013-12-24
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#'
Question by:sagardeo
    LVL 5

    Accepted Solution

    try this.

    select * .... and left(zip,5) = '#Trim(FORM.Password)#'
    LVL 7

    Assisted Solution

    How about...

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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now