Title: Referencing wp_users
Last modified: August 19, 2016

---

# Referencing wp_users

 *  [shadd](https://wordpress.org/support/users/shadd/)
 * (@shadd)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/referencing-wp_users/)
 * Hi Guys,
 * I am trying to link a foreign key to the wp_users ID column but mysql keeps telling
   me that I am using the wrong syntax between ‘REFERENCES wp_users(ID)’
 * Table below:
 * CREATE TABLE my_comments (
    comment_id integer auto_increment NOT NULL, comment_target_id
   integer NOT NULL, comment_target_tablename varchar(120) NOT NULL, comment_author
   varchar(120) NOT NULL, comment_date date NOT NULL, comment_content text NOT NULL,
   comment_approved tinyint(1) NOT NULL, comment_author_ip_address varchar(30) NOT
   NULL, user_id integer NOT NULL, PRIMARY KEY(comment_id), FOREIGN KEY user_id 
   REFERENCES wp_users(ID) );

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/referencing-wp_users/#post-1291436)
 * Try: FOREIGN KEY (user_id) REFERENCES wp_users(ID)

Viewing 1 replies (of 1 total)

The topic ‘Referencing wp_users’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/referencing-wp_users/#post-1291436)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
