2
INSERT IGNORE INTO table3
(id1,   id2) VALUES
SELECT id1, id2 FROM table1, table2;

What's wrong with the above SQL query?

It shows me syntax error.

3 Answers 3

5

Remove the word VALUES. See here for spec:

INSERT IGNORE INTO table3
(id1,   id2) 
SELECT id1, id2 FROM table1, table2;

And note Russ' response.

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

3 Comments

Thanks a lot. Unfortunately i did not care about it. :(
@Saiful: what is this it that you refer to?
can't they relax this rule, made me go mad
2

Remove "VALUES".

Oh, and by the way, you've got a cartesian join. You should add syntax to join table1 to table2.

1 Comment

+1 for catching the cartesian join. That could cause a lot of pain... unless OP actually wants that...
0

try this

INSERT IGNORE INTO table3(id1,   id2) 
SELECT id1, id2 FROM table1, table2;

VALUES is not used in combination with a SELECT statement

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.