probably a stupid question

2003-06-18 Thread Jonas Geiregat
Hey, Here is what I want to do I have 2tables let's say table A and B for simplicity. in table A I have column id and in table B I have column A_id I insert a new value into table A insert into a values(NULL) Since id is auto_incremenet and the primary key it will have an auto value. Now I want

RE: probably a stupid question

2003-06-18 Thread Twibell, Cory L
Check out LAST_INSERT_ID() in the manual -Original Message- From: Jonas Geiregat [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 18, 2003 12:26 PM To: 'Mysql' Subject: probably a stupid question Hey, Here is what I want to do I have 2tables let's say table A and B for simplicity

Re: probably a stupid question

2003-06-18 Thread Don Read
On 18-Jun-2003 Jonas Geiregat wrote: snip I insert a new value into table A insert into a values(NULL) Since id is auto_incremenet and the primary key it will have an auto value. Now I want that the column A_id contains that id nr. I could query for the biggest id in column A and insert

RE: probably a stupid question

2003-06-18 Thread Andy Eastham
Jonas, After the insert, execute SELECT LAST_INSERT_ID(); This always gives the last auto increment value generated by your database connection. Andy -Original Message- From: Jonas Geiregat [mailto:[EMAIL PROTECTED] Sent: 18 June 2003 19:26 To: 'Mysql' Subject: probably a stupid

Re: probably a stupid question but...

2001-07-08 Thread Jonah Klimack
Use an index If you mean use a primary key to create a unique record regardless of the other data in the row, I've already done that. However I'm using that primary key as a means of creating a relationship with another table. What I don't want, is the same category name and customerID twice,

Re: probably a stupid question but...

2001-07-08 Thread Don Read
On 08-Jul-01 Jonah Klimack wrote: What I don't want, is the same category name and customerID twice, even if it does have an index column that differentiates it from other rows. I've tried this: ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, customerID INT UNSIGNED, categoryname

probably a stupid question but...

2001-07-07 Thread Jonah Klimack
Hi I want to enforce unique records in one of my tables. The table goes like this: ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, customerID INT UNSIGNED, categoryname VARCHAR(20) With customer ID pointing to a customers table. I suddenly realized that one customer could input the same

Re: probably a stupid question but...

2001-07-07 Thread Justin Farnsworth
Use an index. -- Jonah Klimack wrote: Hi I want to enforce unique records in one of my tables. The table goes like this: ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, customerID INT UNSIGNED, categoryname VARCHAR(20) With customer ID pointing to a customers table.