Title: How WordPress Generates Primary Keys
Last modified: August 19, 2016

---

# How WordPress Generates Primary Keys

 *  [ottobonn28](https://wordpress.org/support/users/ottobonn28/)
 * (@ottobonn28)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/how-wordpress-generates-primary-keys/)
 * Hi,
 * Does anyone know how WordPress generates its primary keys for things like links
   and link categories? I’m looking to do something similar, which involves joining
   two database tables with a linking table (a many-to-many relationship). The tables
   each have single primary keys. The problem is that the keys are automatically
   generated with MySQL’s AUTO INCREMENT facility, so it’s hard to know what key
   the database assigns. Since this is very similar to the way WordPress handles
   links and categories, I was hoping someone knew how WordPress does it.

The topic ‘How WordPress Generates Primary Keys’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [key](https://wordpress.org/support/topic-tag/key/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * 0 replies
 * 1 participant
 * Last reply from: [ottobonn28](https://wordpress.org/support/users/ottobonn28/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/how-wordpress-generates-primary-keys/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
