0

When I run this query it returns 6,338 total rows.

  SELECT updated.playerId
  FROM updated WHERE updated.updated = 0;

However, when I run this query it only inserts 2,771 total rows, when it should insert all 6,338.

  INSERT IGNORE INTO playerold (playerID)
  SELECT updated.playerId
  FROM updated WHERE updated.updated = 0;

Am I missing something here?

Koala
  • 5,253
  • 4
  • 25
  • 34

2 Answers2

1

If you see the error you need to remove the word IGNORE your sql statement. I think you have a different constraint in another table. Check table constraints.

You can try CREATE TABLE playerold SELECT playerID FROM updated WHERE updated.updated = 0;

Ivan Rodriguez
  • 426
  • 4
  • 14
1

1 Remove the unique constraint available in playerold table if you want all the records and use the below query:

 INSERT INTO playerold (playerID)
 SELECT updated.playerId
 FROM updated WHERE updated.updated = 0;

Or,

2 Try:

 INSERT INTO playerold (playerID) VALUES (SELECT updated.playerId
 FROM updated WHERE updated.updated = 0) ON DUPLICATE KEY UPDATE playerID=playerID
ngrashia
  • 9,869
  • 5
  • 43
  • 58