0

I have a table with two columns user_x and user_y which is combined into primary key. So now inserting duplicating records like 1,2 and 1,2 is impossible. But how to prevent insertion reversed combinations like 1,2 and 2,1? Via query that alter table or in phpmyadmin.

  • Actually, [the solution provided in this post](http://stackoverflow.com/questions/14247655/mysql-check-constraint) is probably better. – Zohar Peled Apr 30 '15 at 10:46
  • I would argue for a third solution: Deliberately insert both rows, but use a flag to identify the 'true' one. – Strawberry Apr 30 '15 at 11:40

0 Answers0