If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > SQL statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-11, 05:22
JohnPapa JohnPapa is offline
Registered User
 
Join Date: Sep 2011
Posts: 2
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?
Reply With Quote
  #2 (permalink)  
Old 09-19-11, 06:28
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 09-19-11, 10:59
JohnPapa JohnPapa is offline
Registered User
 
Join Date: Sep 2011
Posts: 2
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On