1

Below is my mysql Query:

CREATE TEMPORARY TABLE temp_user_Details (
    user_id INT(10) NOT NULL,
    user_name NVARCHAR(100) NOT NULL,
    user_email NVARCHAR(100) NOT NULL
);


INSERT INTO temp_user_Details (user_id, user_name, user_email)
    (SELECT user_id, CONCAT(first_name," ",last_name) AS UserName, email
        FROM users WHERE reportingManager = "abcd");

I am getting the following error:

Error Code: 1242.

Subquery returns more than 1 row.

I am no able to understand what exaclty is the error as in users table user_id column is primary key and auto incremental.

Kostas Mitsarakis
  • 4,772
  • 3
  • 23
  • 37
Rahul Munjal
  • 2,551
  • 2
  • 15
  • 35

1 Answers1

0

That's strange. My guess is that it is caused by the parentheses? Have you tried removing them, like this? Also, the alias has no use being there.

INSERT INTO temp_user_Details (user_id,user_name,user_email)
 SELECT user_id,CONCAT(first_name,' ',last_name),email
FROM users WHERE reportingManager = 'abcd';
Ruslan
  • 2,691
  • 1
  • 19
  • 29