0

With following query I retrieve some names from a table

query = "SELECT lastname FROM `firsttable` WHERE grp = 'C' AND av = '0' "

Caleb
Collins
Fiandre
Francis
Garmont
Gavelot
Maxima
Power
Zanzibar
Zavinsly
Saccult
Stancovich
Pedrocet

then these values must be inserted in another table with following query and this order

insert = "INSERT INTO `alldata` (name, year, month) VALUES ('%s', '%s', '%s') "%(lastname, yearold, monthold)

Caleb
Collins
Gavelot
Fiandre
Francis
Garmont
Maxima
Pedrocet
Power
Saccult
Stancovich
Zanzibar
Zavinsly
Ryan Day
  • 113
  • 1
  • 8
  • 1
    Use a `INSERT INTO` with a `SELECT` Example: `INSERT INTO table2 (column1, column2, column3) SELECT column1, column2, column3 FROM table1 WHERE condition;` – Zak Jul 18 '23 at 15:30
  • 1
    Does this answer your question? [INSERT with SELECT](https://stackoverflow.com/questions/5391344/insert-with-select) – Zak Jul 18 '23 at 15:32
  • Not exactly what I need, but I understand the principle and will work on that. – Ryan Day Jul 18 '23 at 16:10

0 Answers0