0

For some reason I get the following error when running the code below:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM postcodes_demographics INNER JOIN latlon1 on postcodes_demographics.postc' at line 3

I don't understand what I'm doing wrong, thanks for any suggestions!

INSERT INTO pslatlong
    SELECT postcodes_demographics.*, latlon1.*,
    FROM postcodes_demographics
    INNER JOIN latlon1
    on postcodes_demographics.postcode = latlon1.postcodens;
1
  • 3
    Remove the comma at the end of the select clause. Commented Apr 24, 2014 at 12:56

3 Answers 3

1

You have an errant comma:

 SELECT postcodes_demographics.*, latlon1.*, <--- HERE

Remove it.

Sign up to request clarification or add additional context in comments.

Comments

1

I would be very surprised if merely removing the comma fixes the problem. When using insert, you should get in the habit of listing all the columns explicitly:

INSERT INTO pslatlong(col1, col2, . . . )
    SELECT d.col1, l.col2, . . .
    FROM postcodes_demographics d INNER JOIN
         latlon1 ll
         on d.postcode = ll.postcodens;

You need to do this to be sure that the right column is assigned the right value, to allow auto incrementing columns to be auto-incremented, and to prevent problems based on the number of columns.

Comments

0

This may works:

INSERT INTO pslatlong
 SELECT postcodes_demographics.*, latlon1.*
 FROM postcodes_demographics
 INNER JOIN latlon1
 on postcodes_demographics.postcode = latlon1.postcodens;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.