0

I have a table called CountriesList with ID and Country columns.
I have another table called Entries which have a column named Country.

I would like to INSERT all the countries in Entries into CountriesList... I am using the following syntax:

INSERT INTO CountriesList ('Country') 
SELECT DISTINCT ('Country')
FROM  `Entries`

However, I get

1064 - You have an error in your SQL syntax

What is wrong with the syntax?

4 Answers 4

4

Don't mix up single quotes (') and backticks (`).

Backticks are for database and column names.

Single quotes are used for strings.

INSERT INTO `CountriesList`
(`Country`) 
SELECT DISTINCT `Country` FROM `Entries`
Sign up to request clarification or add additional context in comments.

Comments

2
Insert into entries(country) 

     select distinct(country) from 

    countrylist where country not in

     (select country from entries)

Comments

0

It should be -

INSERT INTO CountriesList
(Country) 
SELECT DISTINCT Country FROM  Entries

Comments

0

try this insert into Entries (country) select country from CountriesList

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.