-4
INSERT INTO person_data('Key','value',Person_id)
SELECT 'aaa','bbb',1, FROM person_data;

could someone please indicate what is the issue with the above statement? is that because 'key' and 'value' are sensitive words? Any help?

Raging Bull
  • 18,593
  • 13
  • 50
  • 55
Max
  • 35
  • 5

3 Answers3

2

Key is a column name which also happen to be keyword and should not be put inside qoutes but backticks. Also remove last comma in Select list.

INSERT INTO person_data 
            ( ` KEY ` , 
             value, 
             person_id) 
SELECT 'aaa', 
       'bbb', 
       1 
FROM   person_data; 
Community
  • 1
  • 1
Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133
1
INSERT INTO person_data(`Key`,`value`,`Person_id`) VALUES ('$key', '$value', '$Person_id') 
SELECT *  FROM person_data;
wild
  • 340
  • 1
  • 3
  • 14
0

There is no need to quote the column names. Try this:

INSERT INTO person_data(Key,value,Person_id) SELECT 'aaa','bbb',1, FROM person_data;