This is my sample query request:
SELECT item from tbl
And here is the result:
1001 2001
Is there a function in MySQL that allows me to insert characters into a value in my select query? Like this:
1-001 2-002
Using the INSERT () function . Your code should look something like this:
SELECT INSERT(item, ,2, 0, '-') item from tbl
SELECT CONCAT_WS('-', LEFT(item, 1), SUBSTRING(item, 2)) FROM tbl
Try the following: -
SQL DEMO
Try this one
SELECT CONCAT(LEFT( `item ` , 1) ,'-' ,`item`) FROM `tbl`
or
SELECT CONCAT(LEFT( `item ` , 1) ,'-' ,SUBSTRING(`item`,2) FROM `tbl`
The syntax will be:
INSERT (ori_string, in_pos, length, new_string)