I need to copy a row .
Copied row,I need to change value, this value + 'copy'
I made this sql..but it's not work..
INSERT INTO prizes_i18n (
lang_id
, translation_name
, translation_desc
, name
, lang_path)
SELECT prizes_s.lang_id
, prizes_s.translation_name + 'copy'
, prizes_s.translation_desc
, prizes_s.name
, prizes_s.lang_path
FROM prizes_i18n prizes_s
WHERE prizes_s.lang_id = 637;
Without + 'copy' its works.
Like this prizes_s.translation_name + 'copyy'
,but it's not work.
You can use a select-statement within an INSERT statement to insert zero, one, or more rows into a table from the result table of the select-statement. The select-statement embedded in the INSERT statement is no different from the select-statement you use to retrieve data.
The INSERT INTO SELECT statement copies data from one table and inserts it into another table. The INSERT INTO SELECT statement requires that the data types in source and target tables match. Note: The existing records in the target table are unaffected.
INSERT INTO SELECT statement in SQL Server is used to copy data from the source table and insert it into the destination table. The SELECT INTO statement in SQL Server is used to copy data from one (source) table to a new table. INSERT INTO SELECT requires the destination table to be pre-defined.
From this previous question you use MySQL? If so use concat
for string concatenation.
SELECT 'foo' + 'bar' ...
Returns 0
in MySQL which would explain the error about doubles you are seeing.
INSERT INTO prizes_i18n (lang_id, translation_name, translation_desc,
name, lang_path)
SELECT prizes_s.lang_id,
concat(prizes_s.translation_name, 'copy'),
prizes_s.translation_desc, prizes_s.name, prizes_s.lang_path
FROM prizes_i18n prizes_s WHERE prizes_s.lang_id = 637;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With