0

I have a table named user in database named client. user has the structure as follows:

`fkey`(varchar(100)) | `status`(enum('1','0'))

I have another database named employees with a table named employee It has a cloumn named emailid which has all the data I need.

I want all the emailid column data from employees.employee to be inserted in client.user at fkey column.there is another column status in client.user which needs to be set as 1 .How do I create a query for this.

This is my query but it is wrong.

insert into client.user (`fkey`,`status`) select `emailid` from employees.employee,'1';
Francis
  • 147
  • 3
  • 15
  • https://stackoverflow.com/questions/5907206/mysql-insert-into-tbl-select-from-another-table-and-some-default-values – Shubhranshu Nov 20 '17 at 07:22

1 Answers1

1

Definitely it’s wrong syntax . It should be

Insert into client.user (fkey,status) select `emailid`, '1' from employees.employee 
Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43
kartik
  • 110
  • 1
  • 1
  • 10