Vishal Kawade
Vishal Kawade

Reputation: 443

insert data into table by extracting data from other table

I am trying to insert values by extracting from another table but I got exceptionsqlsyntax error while trying this way

int row=st.executeUpdate("insert into bug_history (bug_h_id,type,summary,desc,ans) 
select bug_id,type,summary,desc,solution 
from bug_details 
where bug_id="+bug_id);

Upvotes: 2

Views: 51

Answers (1)

Vicky Thakor
Vicky Thakor

Reputation: 3916

Change your query as follow. Use Backtick symbol

INSERT INTO bug_history (`bug_h_id`, `type`, `summary`, `desc`, `ans`) 
SELECT `bug_id`, `type`, `summary`, `desc`, `solution` 
FROM   bug_details 
WHERE  bug_id = bugID 

Upvotes: 1

Related Questions