This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-24. For the latest, interactive version please visit https://mariadb.com/kb/.

INSERT SELECT

Sintassi

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
    [INTO] nome_tabella [(nome_colonna, ...)]
    SELECT ...
    [ ON DUPLICATE KEY UPDATE nome_colonna=espr, ... ]

Spiegazione

Con INSERT ... SELECT, è possibile inserire molte riga in una tabella, prelevandole da un'altra o da più tabelle. Esempio:

INSERT INTO tabella_temp2 (campo_id)
  SELECT tabella_temp1.campo_id_ordine
  FROM tabella_temp1 WHERE tabella_temp1.campo_id_ordine > 100;
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.