samedi 27 juin 2015

insert from multiple tables into other

I would like to insert data from many tables into just one, I'm trying this but it's not working, what is the correct way of doing this?

INSERT INTO geo_lists AS a
LEFT JOIN en AS b
LEFT JOIN fr AS c
LEFT JOIN de AS d
LEFT JOIN zh_cn AS e
LEFT JOIN es AS f
LEFT JOIN ru AS g
LEFT JOIN pt_br AS h
VALUES
    a.city_id = b.geoname_id,
    a.continent_code = b.continent_code,
    a.continent_name = b.continent_name,
    a.country_code = b.country_iso_code,
    -- countries
    a.en_country_name = b.country_name,
    a.fr_country_name = c.country_name,
    a.de_country_name = d.country_name,
    a.zh_country_name = e.country_name,
    a.es_country_name = f.country_name,
    a.ru_country_name = g.country_name,
    a.pt_country_name = h.country_name,
    -- states
    a.en_state_name = b.subdivision_1_name,
    a.fr_state_name = c.subdivision_1_name,
    a.de_state_name = d.subdivision_1_name,
    a.zh_state_name = e.subdivision_1_name,
    a.es_state_name = f.subdivision_1_name,
    a.ru_state_name = g.subdivision_1_name,
    a.pt_state_name = h.subdivision_1_name,
    -- provinces
    a.en_province_name = b.subdivision_2_name,
    a.fr_province_name = c.subdivision_2_name,
    a.de_province_name = d.subdivision_2_name,
    a.zh_province_name = e.subdivision_2_name,
    a.es_province_name = f.subdivision_2_name,
    a.ru_province_name = g.subdivision_2_name,
    a.pt_province_name = h.subdivision_2_name,
    -- cities
    a.en_city_name = b.city_name,
    a.fr_city_name = c.city_name,
    a.de_city_name = d.city_name,
    a.zh_city_name = e.city_name,
    a.es_city_name = f.city_name,
    a.ru_city_name = g.city_name,
    a.pt_city_name = h.city_name,
    a.time_zone = b.time_zone;

To store especial characters from different languages, the correct charset and collation is utf8 and utf8_general_ci? Or do I need to change it?

Aucun commentaire:

Enregistrer un commentaire