B
B
berapru2016-04-27 14:40:35
MySQL
berapru, 2016-04-27 14:40:35

How to conveniently update/load data into a MYSQL table?

Good afternoon!
New fields appeared in the table, you need to bulk load data into them, a bunch through id.
Table example:
https://yadi.sk/i/KfiwCk6hrL6iT
UVU2kvI9C_5KALQlX8L8oDnoexgIhGzfFq7rMiQ9
Sample data to upload
https://yadi.sk/i/W9xTo2rkrL6uV
UVU2kvI9C_5KALQlX8L8oM37VNqbug_GhDcOo4az
Tried doing this using INSERT INTO

INSERT INTO regions (country_id,rf_geo_region_id,rf_geo_municipal_districts
  ,city,city2,additional_geo_info,id) VALUES
  (1,47,,'г. Улан-Удэ',,,1),
  (1,47,,,,,2),
  (1,47,,'г. Северобайкальск',,,3),
  (1,47,'р-н Северо-Байкальский',,,,4),
  (1,47,'р-н Северо-Байкальский','пгт. Нижнеангарск',,,5),
  (1,47,'р-н Северо-Байкальский','пгт. Новый Уоян',,,6),
  (1,47,'р-н Баргузинский',,,,7),
  (1,47,'р-н Муйский',,,,8),
  (1,47,'р-н Муйский','пгт. Северомуйск',,,9),
  (1,47,'р-н Бичурский',,,,10),
  (1,47,'р-н Джидинский',,,,11),
  (1,47,'р-н Еравнинский',,,,12),
  (1,47,'р-н Баунтовский эвенкийский',,,,13),
  (1,47,'р-н Заиграевский',,,,14),
  (1,47,'р-н Закаменский',,,,15),
  (1,47,'р-н Кабанский',,,,16),
  (1,47,'р-н Иволгинский',,,,17),
  (1,47,'р-н Кижингинский',,,,18),
  (1,47,'р-н Кяхтинский',,,,19)
ON DUPLICATE KEY UPDATE 
  country_id = VALUES(country_id),
  rf_geo_region_id = VALUES(rf_geo_region_id),
  rf_geo_municipal_districts = VALUES(rf_geo_municipal_districts),
  city = VALUES(city),
  city2 = VALUES(city2),
  additional_geo_info = VALUES(additional_geo_info);

Gives an error
https://yadi.sk/i/qyJq5B--rL7j7
UVU2kvI9C_5KALQlX8L8oJDnW07rMlgm7lUWj5U7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-04-27
@Rsa97

The first data set does not have a value for rf_geo_municipal_districts. You must specify either '' or NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question