handling duplicate records in mysql Insert statement

前端 未结 4 1861
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 10:59

Im i have a php form to enter data into a mysql database, my question is how do i handle duplicate records for example if an ID number already exsists how do i check if exsists

4条回答
  •  猫巷女王i
    2021-01-26 11:34

    Add a unique index constraint on the loan_id column. MySQL will throw an error when your application attempts to insert another row with the same value.

    SQL will look similar to:

    CREATE UNIQUE INDEX loan_id_index ON table_name (loan_id);
    

提交回复
热议问题