CodeIgniter Forums
Primary and unique field - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Primary and unique field (/showthread.php?tid=44994)



Primary and unique field - El Forum - 09-03-2011

[eluser]zlatiborac[/eluser]
I have a very simple table with two columns, id which is primary and name which is unique.
When I insert data in this table and try
Code:
select * from tags
I receive this result
Code:
mysql> select * from test;
+----+-------+
| id | name |
+----+-------+
| 2 | drugi |
| 1 | prvi |
| 3 | treci |
+----+-------+
3 rows in set (0.00 sec)
which is very odd.
But if I remove unique attribute from second column (name) I get the result as expected
Code:
mysql> select * from test;
+----+-------+
| id | name |
+----+-------+
| 1 | prvi |
| 2 | drugi |
| 3 | treci |
+----+-------+
Can anyone explain what happened here and why is this happening.