MySQL insert into + select Insert statement

Gentle just because of you 2022-05-22 12:05:41 阅读数:415

mysqlinsertselectinsertstatement

Mysql insert into + select Insert statement

  1. Grammatical structure

    INSERT INTO
    Table name ( Field 1, Field 2....)
    SELECT
    Field 1,
    Field 2....
    FROM
    The name of the table
    WHERE
    Conditions
    
  2. Realization (Insert The inserted field name should be the same as select The number of field names after is the same , And one by one , Insert directly into database )

    INSERT INTO
    sys_role_menu (menu_id, role_id)
    SELECT
    ru.menu_id,
    1 AS role_id
    FROM
    sys_role_menu ru
    WHERE
    ru.role_id != 1
    
copyright:author[Gentle just because of you],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/142/202205211807120966.html