K
K
Kesha202020-02-27 17:25:14
MySQL
Kesha20, 2020-02-27 17:25:14

How to dynamically copy a value from one table to another with checking for MySQL row repetitions?

I have a webfrom table with id name value rows in it, each id has its own value in name value
For example id 1 , name country (value Russia), name city (value Moscow)

I created a table named it addresses in it rows id , address, coords
How can I copy the values ​​from the webfrom table so that the id value is transferred to the addresses table in the id row, and from city and country to the address row of the addresses table in the format Russia, Moscow?

At the same time, this query will be executed once a day and check if the same value already exists in the webfrom table that is already in the addresses table, for example, Russia, Moscow has already entered the addresses table, if such a value appears again in the webfrom table, then its needs to be excluded to be added to the addresses table.

In the future, the coordinates that I will receive using GeoCoder will be written to the coords line.

Tell me in which direction to dig at all? At least the simplest example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Sviridov, 2020-02-27
@dimuska139

You need to use INSERT...SELECT in conjunction with ON DUPLICATE KEY IGNORE.

K
Kesha20, 2020-02-27
@Kesha20

Solved the question in a different way, not related to the topic of the question. Can I close the issue?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question