Search code examples
mysqlsqlmysql-workbenchconcatenationstring-concatenation

CONCAT last number in column in a string


I'm trying to create a CONCAT() that gets the last number in the exp_id column, then adds the filename to display as a separate column. The column would display the following.

copy \\\resfs\reo\reoexps\87\5\7040445i.pdf C:\temp\images 
CONCAT('copy \\\resfs\reo\reoexps\87\',', SUBSTRING(exp_id, 1,CHAR_LENGTH(exp_id) -1) '\', file_name, 'C:\temp\images') AS D,

enter image description here
enter image description here

enter image description here


Solution

  • try this:

    CONCAT('copy ','\\','\\','\\','resfs\\reo\\reoexps\\87\\', SUBSTRING(CAST(exp_id AS char), 1,CHAR_LENGTH(exp_id) -1),'\\', file_name, ' C:\\temp\\images') AS D