AS400 SQL Concatenation

I needed to concatenate some information in a table, and I wanted to do it with a SQL query, but I could not for the life of me figure out how to combine the two strings (one a constant, the other a field name) in order to produce a joined value.

Finally, I found it- concat.

 update tablename
 set fieldname = 'constant' concat 'fieldname'

I don’t know why this took me so long to find, but I just could not come up with it.

In any case, this will do the trick.

Also, a note that may be of some significance to you: This will likely be the last AS400 bit I do here in Code Talking for a while. It seems that I’m currently unemployed and looking for a new opportunity. That new opportunity may include an AS400, it may not. But I’ll likely not be doing anything on an AS400 for at least a little bit.


Posted

in

Comments

One response to “AS400 SQL Concatenation”

  1. betty Avatar
    betty

    AS400 SQL question
    Can you override a data base file to the name used in the select clause? Or does the name in the select have to be a real file name. I am trying to count the records in a file. I wanted to be able to use a generic name and override to it. Will that work. So far it hasn’t. I get 0.