Update Query To Append Text To A Field

R

rpm

Is there a way to construct an update query so that it will append
specific text to an existing field?

For Example I have the following fields:

Item_No
Vendor_No
Vendor_Cat_No

A sample table shows:

Item_No Vendor_No Vendor_Cat_No

545 1234 17-123
100 1650 FR100
721 1234 AB1234

The update query would add the prefix "JH-" to the Vendor_Cat_no field
if Vendor_No = 1234

So the table would be updated to look as follows:

Item_No Vendor_No Vendor_Cat_No

545 1234 JH-17-123
100 1650 FR100
721 1234 JH-AB1234

Any help would be appreciated

rpm
 
C

Céline Brien

Hi rmp,
I am not to good at SQL to I use little tricks.
First :
Create a table containing :
Vendor_No Vendor_Letter
1234 JH
1650 ???

Second :
Query creating a table with field
Vendor_No Vendor_No Vendor_Cat_No Vendor_Cat_No2
Vendor_Cat_No2:[Vendor_Letter]&"-"&[Vendor_Cat_No]

Third :
Use that last table to update your table.
But I am sure you will a better suggestion than that.
Have a good day,¸
Céline
 
J

John Nurick

Something like this should do it:

UPDATE MyTable SET Vendor_Cat_No = 'JH-' & Vendor_Cat_No
WHERE Vendor_No = 1234;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top