how avoid dublicate data to mysql

后端 未结 3 1395
眼角桃花
眼角桃花 2021-01-28 11:27

I write the code to scrap car info(title, make, model, transmission, year, price) data from ebay.com and save in the mysql, I want if all row\'s(title, make, model, ...) item\'s

3条回答
  •  野性不改
    2021-01-28 12:02

    You could save the result of this query into a variable

    SELECT COUNT(*) FROM car_info WHERE Title = , Maker = , Model = , Transmission = , Year = , Price = 
    

    and then, if the value of the variable is

    • 1, you skip the INSERT because you already have this entry in the table
    • 0, you make the INSERT because you do not have that entry in the table

    It's just one way of doing this.

提交回复
热议问题