0

i have a simple project which project give person information to database (sqlite) now i want to avoid from insert duplicate value(by name) what i cant do about it ? thank you guys

White Druid
  • 295
  • 1
  • 12

2 Answers2

1

Just assign UNIQUE to name column. But my suggestion is never set UNIQUE on name column because there are plenty of chances to have same name for more people. Set UNIQUE constraint to another column like ID, email, phone etc.

blb007
  • 15
  • 8
0

You have two options add Name as primary key or check if the name exist before each insert.

SELECT count(*) FROM "table_name" WHERE name = "name"

If it return > 0 don't make the insert.

solamente
  • 266
  • 2
  • 15