Jump to content

DUPLICATE KEY UPDATE


Jaynesh

Recommended Posts

Hello

 

I've got a table.

 

vote(user_id, post_id, up, down)

 

Ive assigned post_id a UNIQUE and setup a DUPLICATE KEY UPDATE in my query.

This prevents the user voting on the same post again.

 

However the post_id isnt linked with user_id so it means that other users can't vote on 'post_id' if it already exists in the table.

 

How do I make it see 'user_id' + 'post_id' as UNIQUE so other user_id's can vote on the same post?

Link to comment
https://forums.phpfreaks.com/topic/241506-duplicate-key-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.