How to insert Distinct Records from Table A to Table B (both tables have same structure)

前端 未结 4 885
天涯浪人
天涯浪人 2021-01-05 15:25

I want to insert only Distinct Records from Table \"A\" to Table \"B\". Assume both the tables has same structure.

4条回答
  •  温柔的废话
    2021-01-05 15:53

    INSERT INTO B SELECT DISTINCT * FROM A
    

    You might not want the id column of the table to be part of the distinct check, so use this solution if that's the case: https://stackoverflow.com/a/5171345/453673

提交回复
热议问题