On Fri, 1 Oct 1999, Mike wrote:
Hi list.
Is there a way to create a serial number for rows ?
lets say that i want to create a table that by default inserts a serial
number into sn column.
Can it be done ?
I guess you're looking for a unique counter for the rows.
CREATE TABLE tbl(
sn int unsigned not null primary key auto_increment,
title char(24)
);
INSERT INTO tbl ('', 'Some title');
INSERT INTO tbl ('', 'Another title');
Some title will have sn = 1 and Another title will have sn = 2
and so on.
So, auto_increment is the work you're looking for.
Check the manual.