is it possible to do 1 sql statement (insert) which you duplicate one of the inserting value from another table and another value you hard code? for eg, profilepic, i want to duplicate the value from another table data. As for displayname, i would like to hard code. This is my sql statement:
insert into registration (profilePic, displayname)
values ( (select profilePic from registration where userId = 143), 'abc' );
Error message from mysql :
Error code:1093. You can't specify target table 'registration' for update in from clause.
Using subqueries within the values clause will not work. You should use the following query instead:
insert into registration (profilePic, displayname)
select (select profilePic from registration where userId = 143), 'abc'
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