Update query

  • Thread starter Thread starter Poppy
  • Start date Start date
P

Poppy

I need to update a field in a particular record but I do not want to
overwrite the contents of this field, just append to the field.

e.g UPDATE tblProd SET authorMemo = authorMemo + "TEST"

How would I go about this ?
 
Poppy said:
I need to update a field in a particular record but I do not want to
overwrite the contents of this field, just append to the field.

e.g UPDATE tblProd SET authorMemo = authorMemo + "TEST"

How would I go about this ?

What you have would work if authorMemo was never Null. This
is a more common way to do it that doesn't care if the field
is null or not:

SET authorMemo = authorMemo & "TEST"
 
Something like:

UPDATE tblProd SET authorMemo = authorMemo + "TEST"
WHERE ProdID = {some unique value to identify the Record}.

Are you aware of the difference between "&" and "+" concatenation operators?
 
I know I never knew there was a difference. Is the only difference the
one that Marshall mentioned? If one is null then the whole string is
null when using the "+". That's news to me.
 
Yep.

Null & "ABC" = "ABC"

and

Null + "ABC" = Null

The phrases we use are + concate. promotes Null but &
concat does not. There are uses for each of them. For
example, if you want to construct the full name including
middle name if avail, you can use:

FullName: [FirstN] & (" " + [MiddleN]) & " " & LastN

The extra space in front of the middle name will not be
added to FullName if the MiddleN is Null.

HTH
Van T. Dinh
MVP (Access)
 
maybe a late response but maybe you find it usefull...

whenever you need to add 2 strings you always use "&".
for numbers use "+"


Van T. Dinh said:
Yep.

Null & "ABC" = "ABC"

and

Null + "ABC" = Null

The phrases we use are + concate. promotes Null but &
concat does not. There are uses for each of them. For
example, if you want to construct the full name including
middle name if avail, you can use:

FullName: [FirstN] & (" " + [MiddleN]) & " " & LastN

The extra space in front of the middle name will not be
added to FullName if the MiddleN is Null.

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
I know I never knew there was a difference. Is the only difference the
one that Marshall mentioned? If one is null then the whole string is
null when using the "+". That's news to me.


.
 
Back
Top