MySQL Forums
Forum List  »  General

SQL Syntax
Posted by: Praveen TS
Date: November 23, 2009 03:51AM

Hi,

I have a scenario, I will explain below.

there is an importing contacts to our site. These contacts will be in the form of CSV files.

The individual contact can have multiple phone email Ids, multiple phone numbers(for ex: perosonal phone, office phone etc)

I have database which is having 2 tables to store it,

The table structure is as follows

contact
(
  id PRIMARY KEY,
  name VARCHAR
);

property_tables
(
 id PRIMARY KEY
 property_name VARCHAR
);


contact_details
(
  id PRIMARY KEY,
  user_id FOREIGN KEY contact.id,
  property_id FOREIGN KEY property_tables(id),
  property_value VARCHAR(255)
)

The values in the property_tables are as follows
SELECT * FROM property_tables;
1      |     Email
2      |     Phone
3      |     Address
4      |     City
We came up this approach where user can update contact details manually.Same contact can i have multiple properties.

My question is , when i get the contact details in the form of CSV file(assume this is the file exported from Outlook express or other standard email servers)

Using
LOAD DATA INFILE
I am importing to Temporary table .

From then,

How do i insert `name` to contact table, get the LAST_INSERT_ID() from this table and insert the remaining properties like email, phone, address etc into contact_details ?LAST_INSERT_ID is the relation between two tables

Any SQL syntax?

Regards,
Praveen



Edited 2 time(s). Last edit at 11/23/2009 10:28PM by Praveen TS.

Options: ReplyQuote


Subject
Written By
Posted
SQL Syntax
November 23, 2009 03:51AM
November 23, 2009 08:51AM
November 23, 2009 10:44PM
November 24, 2009 12:18AM
November 24, 2009 11:18AM
November 24, 2009 12:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.