I know this may be a stupid question to ask but I have really forgotten how to do it.
How do I auto increment a photo ID whenever a record is inserted into mySQL database ?
I would want it to start with 1 for the first record and then subsequently +1 for the next. Thanks
I have set my database column photoID to PK, NN and AI.
The MySQL documentation for AUTO_INCREMENT has a nice, clear example. In brief, if your field has been defined as auto incrementing, e.g.:
then when you do an
INSERT, if you do not specify a value for photoID, the value will auto increment (if you explicitly specify a value of NULL or 0 in the values list, the value will also auto increment):A SELECT would result in
photoIDvalue of 1,anotherFieldvalue of something.