3

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. 

1 Answer 1

5

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'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.