Questions tagged [auto-increment]

a database constraint that automatically increases from the last record when making an INSERT

AUTO_INCREMENT is a flag set on a field in a database table that forces the RDBMS to create a unique identifier for the record. This is useful when no other obvious primary key field is apparent in a record.

Useful questions

Related tags

2677 questions
0
votes
4 answers

How to use mysqli_insert_id with prepared statements?

I have the following code and I'm getting crazy with calling an auto_increment id $sql = "INSERT INTO tablename (x1, x2) VALUES(?,?)"; if($query = $db->prepare($sql)){ $query->bind_param('ss', $x1, $x2); $query->execute(); $id =…
John
  • 261
  • 2
  • 6
  • 16
0
votes
2 answers

figuring out Maximum ID in table

I'm trying to figure out the highest id number (set to 'auto_increment') in my table, I tried SELECT * FROM `mytable` WHERE MAX( `id` ) but get #1305 - FUNCTION xymplydb01.MAX does not exist Is there any other way how I can get this without…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
0
votes
1 answer

For each $i, $i++ display result

I have a function that counts the number of variables equal to one other, I used the technique in php for each, with $i = 1 and whenever they find $i++. My problem is that I would display the results, but now, if I have four results, it displays 1 2…
Tomaw
  • 165
  • 3
  • 5
  • 17
0
votes
2 answers

#1062 - Duplicate entry '1' for key 1 when enabling Auto_increment

When I'm trying to enable auto_increment on a column in phpmyadmin, but I always get this error: #1062 - Duplicate entry '1' for key 1 The column in question is the PK and an INT. It already has several rows in it. Because of this, I tried the…
Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
0
votes
0 answers

How to use two different auto_increment order in one column with mysql?

I have a software, allows users keep their records online, and i'm planning to develop a web-site for publishing those records. Visitors of that website even they are not using my software can publish their own ads too. I want to combine that…
mirza
  • 5,685
  • 10
  • 43
  • 73
0
votes
2 answers

Error with auto_increment while conneted to Postgres via psql and puTTY

I'm getting this error in puTTY. Not sure why, looks right to me ... psql:pierre.sql:10: ERROR: syntax error at or near "AUTO_INCREMENT" LINE 2: c_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, …
user195257
  • 3,186
  • 5
  • 36
  • 49
0
votes
0 answers

Insert with left join with insert and auto increment

I am trying to create a left join with an insert. There are two tables table.a table.b, the id value (which is auto increment) in table.b is used as a foreign key in table.a. Because of a broken process, I need to insert into both tables in one…
codehammer
  • 481
  • 5
  • 8
0
votes
2 answers

How do i auto increment a field in foxpro

I'm using vfp9 but the program may have been written in an earlier language. When i open up the database through vfp, the field is read only, unlike the other fields. Doing it manually (select max + 1) doesn't work on the insert, it just makes the…
DanielST
  • 13,783
  • 7
  • 42
  • 65
0
votes
1 answer

Invoice number auto increment

Invoice Number = Now.Year & Now.Month & ????? how can i add 5 digits that auto increment when the form loads? Expected OUTPUT 20120100001 20120100002 Now.Month Problems# when the month is one digit invoice will be 10 digits while when it is two…
0
votes
1 answer

MySQL Server Stored Procedure AUTO_INCREMENT UNIQUE

I am writing a stored procedure in MySQL Community Server 5.5.16 and I need insert there ID which should auto increment and be unique. I am not sure how to do it. Should I use something like this: Declare Z AUTO_INCREMENT UNIQUE;
user1047517
  • 1,459
  • 2
  • 11
  • 20
0
votes
2 answers

Warehouse management Application - Autoincrement letters for primary key.

Is it possible to natively auto-increment letters in MySql? If not can you suggest and alternative based on the description of my application below? Background: I am building a Warehouse management application. In order to locate items within the…
andrew
  • 5,096
  • 10
  • 43
  • 57
0
votes
2 answers

managing/implementing auto-increment primary key in oracle without triggers

We have many tables in our database with autoincrement primary key ids setup the way they are in MySQL since we are in the process of migrating to Oracle from MySQL. Now in oracle I recently learned that implementing this requires creating a…
pri_dev
  • 11,315
  • 15
  • 70
  • 122
0
votes
1 answer

VBA whats the best way to Increment in loop

What would be a good way to increment each of my ranges for example I need x to copy Range B11:to G20 and paste it to C10 for the second loop. Each Variable has different increments. Im using excel 2010 Any Help is appreciated cause I'm horrible…
user1139384
  • 1
  • 1
  • 1
0
votes
1 answer

autoincrement column in SQL database

I have two value in one table in database which I need to autoincrement. First value is ID it's a primary kay and it is setup as Identity Column and have (Is Identity) - Yes in properties. And how setup my second value (number) to autoincrement.…
user1031034
  • 836
  • 1
  • 14
  • 38
0
votes
1 answer

Getting AUTO_INCREMENT values from an INSERT statement

Okay here's the problem: I have a server and a client that works with this general paradigm: - Client makes a "query" request, and gets a query ID (qid) - Client makes "result" requests using the qid as many times as it wants. When a query is…
xanderflood
  • 826
  • 2
  • 12
  • 22