日期:2014-05-16 浏览次数:20689 次
mysql> create table table1 ( -> field1 int, -> field2 int, -> unique key (field1,field2) -> ); Query OK, 0 rows affected (0.11 sec) mysql> INSERT table1(field1,field2) VALUES(1,2); Query OK, 1 row affected (0.06 sec) mysql> INSERT table1(field1,field2) VALUES(1,2); ERROR 1062 (23000): Duplicate entry '1-2' for key 'field1' mysql> INSERT table1(field1,field2) VALUES(1,1); Query OK, 1 row affected (0.08 sec) mysql> INSERT table1(field1,field2) VALUES(2,2); Query OK, 1 row affected (0.06 sec) mysql>
------解决方案--------------------
跟一个字段没啥区别! 仔细看下手册!