> Hi all,
> I have a question:
> I made a table with a field that is auto_increment. This field I made to be
> the primary key.
> In my opinion an auto_increment field should fill itself, without the
> intervention of the user.
> So if I have a table like:
> f1,f2 --field names, where f1 is auto_increment...
> than in the insert sql statement I should insert only the f2 field, and
> mysql should fill the f1 field with the apropriate value.


Exactly. Pass a null value to the auto_increment field, and it will kick off.

INSERT INTO tablename (f2) VALUES ("xyz");
will automatically create values for f1.

or

INSERT INTO tablename (f1, f2) VALUES (NULL, "xyz");

will have the same effect. The difference is that in the first 
example the null value is implicit, while in the second one it is explicit.

Bye
Giuseppe Maxia


> Or I understood wrong the auto_increment property?
> If so, then what should I do to obtain such a behaviour I mentioned above;
> if not then what I do wrong, what should I do , or how the insert statement
> should look? Thank you..
> best regards emil Jurj (xenon) :))
> 




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to