views:

71

answers:

3
INSERT INTO abc
VALUES (

a, b, c, d, e, f
)
SELECT a, b, c, d, e,f
FROM bcd

when i execute this iam getting synatx errors .how do i get rid of the synatx error

+7  A: 

Are you thinking this?

INSERT INTO abc(a,b,c,d,e,f) SELECT a,b,c,d,e,f from bcd;
aehiilrs
+6  A: 

the problem is you don't use the VALUES keyword when using a select statement to populate the values.

INSERT INTO abc (a,b,c,d,e,f) SELECT a, b, c, d, e,f FROM bcd

Here is a reference for the INSERT syntax

northpole
I win by 42 seconds! :P
aehiilrs
ya, seems to always be the case, which is a good thing, means there is a lot of knowledgeable people that use this site.
northpole
Yeah, I love this site for that exact reason. That little bit of competition just adds to the fun.
aehiilrs
A: 

Here a,b,c,d,e,f are values or field names?

if they are values,

It will be: INSERT INTO abc VALUES('a','b','c','d','e','f');

If they are fields, you have to specify values to insert.

SELECT is ok, if they are fields.

Nikhil K