Hello,
I have a general question about inserting data.
I have the following tables:
CREATE TABLE customer (
client_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
addr_id INT,
account_type INT,
how_hear INT,
cc_type INT,
cc_exp VARCHAR(5),
cc_num VARCHAR(16),
sign_up_date DATE
);
CREATE TABLE addresses (
addr_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
fname VARCHAR(16),
lname VARCHAR(16),
company VARCHAR(72),
addr1 VARCHAR(72),
addr2 VARCHAR(48),
city VARCHAR(32),
state VARCHAR(3),
zip VARCHAR(16),
country VARCHAR(32),
phone VARCHAR(18),
fax VARCHAR(18),
email VARCHAR(74)
);
I need to insert data into both of these tables at one time. I want to have
the "addr_id" field in the addresses tables to be included in the insert of
data to the customer table.
My solution so far is to have 1 insert statement that inserts the
appropriate data into the addresses table (creating a record), then have a
select statement pull back the most recent (which is only milliseconds old)
record from addresses and get the addr_id (it would probably be set to a
variable) then when all other data is gathered for the customer insert the
addr_id would be included in that insert.
This seems really difficult to do a simple insert and I was wondering if
anyone knew if I could use something like a view that would allow me to
insert into multiple tables with one statement? I didn't see anything
reguarding views in the documentation.
Any ideas how to solve this?
Thanks,
Kevin
kevsurf4@hotmail.com
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com