1

Topic: How to find max id and to write down in 2 tables?

Respected , Akina with coming new year! Does not give rest a question as it is possible to find max_id from the table subject and to copy it in the table person, it is desirable the general-purpose method which would allow to interpose at once into 2-3 tables the same max id. There is such request:
"INSERT INTO person (max_id, iin, surname, name)
SELECT iin, surname, name
FROM xml_person
WHERE iin IN (
SELECT xml_person.iin FROM xml_person
LEFT JOIN person ON (xml_person.iin=person.iin) WHERE person.iin IS NULL AND xml_person.done=0)
The table subject:
id
1
2
3
4

2

Re: How to find max id and to write down in 2 tables?

There is a table subject c one column
id_subject
1
2
3
4
There is a second table xml_person:
id, iin, surname, name
1 222 Petrov Petr
And the third table person:
id_subject, iin, surname, name
How it is possible to copy the data from the first table (in which id_subject at once , to five in this case) and the second table in the third?

3

Re: How to find max id and to write down in 2 tables?

jtag;
And how the first table should incorporate to the second?

4

Re: How to find max id and to write down in 2 tables?

The first table subject with the second table xml_person, (well here as though they do not incorporate, they after all do not have general field), i.e. max (id_subject), iin, surname, name.