How do I get the ID of multiple inserted rows in MySQL?

后端 未结 3 1704
陌清茗
陌清茗 2020-11-27 19:59

I am inserting some words into a two-column table with this command:

INSERT IGNORE INTO terms (term) VALUES (\'word1\'), (\'word2\'), (\'word3\');

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 20:48

    Why not just:

    SELECT ID
      FROM terms
     WHERE term IN ('word1', 'word2', 'word3')
    

提交回复
热议问题