Menambah Nomor Urut pada Query

Stuktur tabel :

CREATE TABLE `pegawai` (
`NIP` char(5) collate latin1_general_ci NOT NULL,
`nama` varchar(30) collate latin1_general_ci NOT NULL,
`umur` int(2) NOT NULL,
`alamat` varchar(100) collate latin1_general_ci NOT NULL,

Data tabel awal:


Pada struktur tabel tidak ada field dengan isi nomor urut tiap record, untuk meng-akali-nya kita gunakan query sbb:

select (@row := @row + 1) as RowId, pegawai.* from (select @row := 0) as A, pegawai

Hasil query dengan nomor urut disamping kiri :


Semoga Manfaat ! 😀

Sumber : Man’z Digitalieur


About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on October 19, 2009, in mYsQL and tagged , . Bookmark the permalink. 1 Comment.

  1. thankss gan

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: