skip to Main Content

I get an error when I import sql file in phpmyadmin. Here is an error

--
-- Indexes for table 'tbl_disposisi'
--
ALTER TABLE 'tbl_disposisi'
  ADD PRIMARY KEY ('disposisi_kd'),
  ADD KEY 'fk_tbl_disposisi_tbl_berita_idx' ('arsip_kd')

#1062 - Duplicate entry '2' for key 'PRIMARY'

Does anyone know how to solve it? Thanks in advance

2

Answers


  1. It is as @Akina says, you have multiple rows with the same disposisi_kd

    In reaction to the comment on how te show the duplicates:

    SELECT 
        disposisi_kd , 
        COUNT(disposisi_kd ) as sameIdCount
    FROM
        table_name
    GROUP BY disposisi_kd 
    HAVING sameIdCount> 1;
    

    should do the trick (don’t forget to replace table_name)

    Login or Signup to reply.
  2. you can also choose another primary key or use a couple of columns as primary key if you need:
    https://www.w3schools.com/sql/sql_primarykey.ASP

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search