Results 1 to 3 of 3

Thread: SQL statement

  1. #1
    Join Date
    Sep 2011
    Posts
    29

    Unanswered: SQL statement

    I use Access 03 and I am trying to update field tblTo.strAdd based on the values of tblFrom.str1 and tblTo.str1, with a single SQL statement

    Assume tblFrom.str1 has only one record where string field
    tblFrom.str1 = 456

    tblTo.str1 has string fields 456234, 456789, 4522, 458, 456 with
    tblTo.strAdd being blank in every case.

    I would like to use a single SQL statement to update tblTo.strAdd with
    the value 456 for all tblTo.str1 that BEGIN WITH 456, in this case we
    will update the 3 records where tblTo.str1 is 456234, 456789, 456

    I tried using something like the following in the WHERE of an UPDATE
    but with no success

    (tblTo.str1 LIKE ' " & strValue & "%' )
    where strValue = "456"

    The above is ADO. For DAO I would use * instead of %

    Any ideas?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    is the space after the LIKE ' a typo?
    ' 456%' isn't the same as '456%'
    in fact it looks like your punctuation id up the swanny

    Id try something like:-
    update tblto set stradd = strvalue where str1 like left(strvalue,3)
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2011
    Posts
    29
    healdem, many thanks.

    I managed to get it working, I used

    (LEFT(tblTo.strAC," & lngDigitNum & ") = '" & strACValue & "') "
    where strACValue = tblFrom.strAC

    Doing it the vba way it took more than 6 minutes. Using SQL it takes an acceptable 15 seconds.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •