UPDATE and CAST data

I need to UPDATE and CAST data from two columns with Type int into a single column with Type varchar. The new field is FullDocNo (varchar) with data being cast, concatenated, and copied from DocNo (int) and SequenceNo (int)

Here is the UPDATE statement that I used on a MS Sql Server version of this db with success, but have not been able to find the equivalent for MySql by research and experimentation:

UPDATE Sections SET FullDocNo = CAST(DocNo AS VARCHAR(5))+ ‘-’ + CAST(SequenceNo AS VARCHAR(5))

The error message is:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘VARCHAR(5))+ ‘-’ + CAST(SequenceNo AS VARCHAR(5))’ at line 1

Is there an equivalent MySql query that will accomplish this objective? Thanks in advance for any help that you can provide.

Here is the code that worked:

UPDATE Sections SET FullDocNo = concat( CAST(DocNo AS CHAR(5)), ‘-’, CAST(SequenceNo AS CHAR(5)) );

Sponsor our Newsletter | Privacy Policy | Terms of Service