“Mysql Loop Insert” Code-Antworten

Mysql Loop Insert

CREATE PROCEDURE myproc()
BEGIN
    DECLARE i int DEFAULT 237692001;
    WHILE i <= 237692004 DO
        INSERT INTO mytable (code, active, total) VALUES (i, 1, 1);
        SET i = i + 1;
    END WHILE;
END
DELIMITER;
CALL myproc;
Smoggy Skipper

MySQL foreach Insert

-- You don't use the VALUES keyword when inserting from a SELECT
INSERT INTO gesdoc_docs_authorizations
    (`gesdoc_docs_id`, `id_profil_do`, `autorisation`, `personal_doc`)
SELECT g.id, d.id, 1, 0
FROM gesdoc_docs g
JOIN users_profil_do d
-- If you don't use an ON clause to specify a join condition, it treats all rows as matching, which results in a full cartesian product of the two tables
Mysterious Mamba

Ähnliche Antworten wie “Mysql Loop Insert”

Fragen ähnlich wie “Mysql Loop Insert”

Weitere verwandte Antworten zu “Mysql Loop Insert” auf Sql

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen