i will get straight to the point and i hope my question is understandable because my english is not very well. So, i use mysql 8.0.23 and i have table like this
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
id_mhs | int | NO | PRI | NULL | auto_increment |
nama | varchar(45) | YES | NULL | ||
npm | char(8) | YES | UNI | NULL | |
j_kelamin | enum('L','P') | YES | NULL | ||
t_lahir | date | YES | NULL | ||
alamat | varchar(50) | YES | NULL | ||
kota | varchar(45) | YES | NULL | ||
telepon | varchar(12) | YES | UNI | NULL | |
varchar(50) | YES | UNI | NULL |
And i showed the data like this
id_mhs | nama | npm |
---|---|---|
1 | AA Aditya A | 51411136 |
2 | A Aditya A | 51412371 |
3 | A Dimas A | 51411111 |
4 | A Faisal Dimas | 51411112 |
5 | A Faridah Nur | 51411113 |
The result was right but when i tried this query mysql> select id_mhs, npm from mahasiswa limit 10;
id_mhs | npm |
---|---|
28 | 51411036 |
47 | 51411054 |
83 | 51411100 |
84 | 51411101 |
85 | 51411102 |
The result was sorted by npm not with id_mhs, same result when i use order by npm, then i tried to remove unique constraint in column npm and the data sorted with id_mhs. So, column with unique constraint & string data type will prioritized to sort data than primary key?