473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how can i store 0 in AUTO_INCREMENT columns as 0

Hi everybody,
i am doing web application implemented with php and mysql. i want to
create a table in the database with auto increment eg
CREATE TABLE $TableName_2(
ID int unsigned auto_increment not null,
name text,
PRIMARY KEY(PartID) )");

i know auto_increment must be begun at 1. However, do u guys have any
idea i can start at 0. Because i want to hard code in id = 0 in my
database. Then other peoeple cannot change eg. insert into ....
values.....(0,Admin). In my web application, i didnt set any password
or priviliage. So can i still set id = 0?
Thanks,
Krista
Jul 19 '05 #1
2 2804
Krista wrote:
i know auto_increment must be begun at 1. However, do u guys have any
idea i can start at 0. Because i want to hard code in id = 0 in my
database. Then other peoeple cannot change eg. insert into ....
values.....(0,Admin). In my web application, i didnt set any password
or priviliage. So can i still set id = 0?


I got a better solution. Add another field to your table that tells the
user status (or just wether user is admin or not).

Portability, readability, build in support for different user levels...

Jul 19 '05 #2
Krista wrote:
i know auto_increment must be begun at 1. However, do u guys have any
idea i can start at 0. Because i want to hard code in id = 0 in my
database. Then other peoeple cannot change eg. insert into ....
values.....(0,Admin). In my web application, i didnt set any password
or priviliage. So can i still set id = 0?


I got a better solution. Add another field to your table that tells the
user status (or just wether user is admin or not).

Portability, readability, build in support for different user levels...

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Lamonby | last post by:
Hi, i want to create a unique serial number to my Db entries. I thought the best way would be to add the auto_increment primary key value to a string, then insert it into a table field...
4
by: Pjotr Wedersteers | last post by:
I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued....
2
by: Ittay Freiman | last post by:
i cannot set auto_increment to start from anything other than 1: mysql> create table test (id int unsigned not null auto_increment primary key); mysql> alter table test auto_increment=2; ...
4
by: jjliu | last post by:
i have created the following table: create table test (field1 varchar(100), id integer unsigned not null auto_increment, unique (field1), primary key (id)); When i try to insert some values by...
9
by: Bart Van der Donck | last post by:
Hello, The first column of my table is AUTO_INCREMENT. I fill my table with 5 records with a blanco value in their first field. The first column of my table will then hold the values 1,2,3,4,5...
0
by: Shailesh | last post by:
I made a MyISAM table on mysql 4.0.18 NT with auto_increment column started at 2147483646. The third row I insert fails as expected because the integer range is maxed out. However, if I delete...
2
by: hjyn | last post by:
Hi, how can I add char to auto_increment? For example, the auto_increment is for integer, I want to add a character at the front of that number. Ex: >create table abs (UserID INT(3) NOT NULL...
1
by: Phil Latio | last post by:
Newbie questions here... Reading the MySQL manual regarding InnoDB databases, can someone confirm that: 1. if the server is rebooted, AUTO_INCREMENT reverts back to 1? 2. what happens if the...
2
by: millisami | last post by:
I have a table with a primary varchar key and some others columns. I want to add a new column at the begining of the table which is Numeric auto_increment. When I add this new column via phpMyAdmin,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.