How do I remove duplicate records in a join table in PostgreSQL?
9
votes
2
answers
14880
views
I have a table that has a schema like this:
create_table "questions_tags", :id => false, :force => true do |t|
t.integer "question_id"
t.integer "tag_id"
end
add_index "questions_tags", ["question_id"], :name => "index_questions_tags_on_question_id"
add_index "questions_tags", ["tag_id"], :name => "index_questions_tags_on_tag_id"
I would like to remove records that are duplicates, i.e. they have both the same
tag_id
and question_id
as another record.
What does the SQL look like for that?
Asked by marcamillion
(205 rep)
Mar 13, 2013, 12:49 AM
Last activity: Oct 20, 2024, 11:42 PM
Last activity: Oct 20, 2024, 11:42 PM