-4
我的數據庫是如果記錄不存在,如何在mysql中插入?
表
id | new_id | affiliate_id | s_percent | a_percent | date
---+---------+----------------+-----------+-----------+--------------
32 | 970 | 34 | 0.25 | 0.2 | 1404387120
33 | 972 | 29 | 0.25 | 0.2 | 1404482095
34 | 973 | 26 | 0.25 | 0.33 | 1405752775
,我想在這裏插入新的記錄。如果new_id
在其列已經存在,那麼它不插入
概念,你將需要:'primary_key'它不是'db'它是你的'表structure'。並請看看:http://stackoverflow.com/questions/913841/mysql-conditional-insert –
是的,這是我的表..以及我應該怎麼做在這種情況下? – user3214124
如果我理解正確,你需要'new_id'列的唯一鍵,以確保'new_id'中有唯一值...因此,如果'new_id'值已經在表中,插入將不會插入該行 –