Title: wpdb-insert Duplicate
Last modified: August 19, 2016

---

# wpdb-insert Duplicate

 *  [aiwarrior](https://wordpress.org/support/users/aiwarrior/)
 * (@aiwarrior)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/wpdb-insert-duplicate/)
 * Hi
    Recently i have been developing some code. Heres what i have been trying 
   to do:
 * 1-> I create a table just like advised in the codex
    2-> I have a function that
   check for some data and tries to set it in the created tables using the wpdb-
   insert function.
 * My DB has this structure:
    $sql = “CREATE TABLE ” . $table_name . ” (
 *  post_name VARCHAR(15) NOT NULL,
 *  url VARCHAR(55) NOT NULL
 *  UNIQUE KEY id (id));”;
 * The problem is that wpdb-insert is making duplicate entries each time the function
   runs. From what i have read i thought that insert default behaviour was to return
   an error if the entry already existed. I wanted to refrain from making a query
   to check if that entry already existed but i was unable to find a solution. Do
   you have any suggestion?
 * Thanks

The topic ‘wpdb-insert Duplicate’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [duplicate](https://wordpress.org/support/topic-tag/duplicate/)
 * [duplicates](https://wordpress.org/support/topic-tag/duplicates/)

 * 0 replies
 * 1 participant
 * Last reply from: [aiwarrior](https://wordpress.org/support/users/aiwarrior/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/wpdb-insert-duplicate/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
