0

Is posible on insert query use auto-increment to concatenate with string for one column value?

The current AUTO-INCREMENT is = 89 name columns pkey

Example query string:

INSERT INTO `Tbl` (`ProcessCod`, `ProcessName`, ) VALUES(CONCAT('f-pdf-',AUTO-INCREMENT), 'Text-Description');

All in one query???

update i think on a string like this:

INSERT INTO `Tbl` (
    `ProcessCod`, 
    `ProcessName`)
VALUES(
    SELECT CONCAT('f-pdf-',`AUTO_INCREMENT`) 
    FROM  INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'INFO'
    AND   TABLE_NAME   = 'Tbl',
    'Text-Description'
);

the scope of my question is around the use of auto-increment (no primary key) to fill a column with it and concatenating with a dinamic string not a static prefix.

walter nuñez
  • 179
  • 1
  • 15

1 Answers1

0

i have solved with this code:

INSERT INTO Tbl (
    ProcessCod, 
    ProcessName
)VALUES(
    (SELECT CONCAT('f-pdf-',`AUTO_INCREMENT`) 
    FROM  INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'INFO'
    AND   TABLE_NAME   = 'Tbl'),
    'Text-Description'
);

it was necessary to place the Select in parentheses so that it works correctly.

walter nuñez
  • 179
  • 1
  • 15