MySQL: How to insert a record for each result in a SQL query?

前端 未结 5 1624
情话喂你
情话喂你 2021-01-30 12:36

Say I have a select

SELECT DISTINCT id, customer_id, domain FROM config WHERE type = \'foo\';

which returns some records.

How can I do

5条回答
  •  庸人自扰
    2021-01-30 13:01

    Execute this SQL statement:

    -- Do nothing.
    

    You want to select distinct rows from "config", and insert those same rows into the same table. They're already in there. Nothing to do.

    Unless you actually just want to update some or all of the values in the "domain" column. That would require an UPDATE statement that really did something.

提交回复
热议问题