Bus Winker
I have a bunch of contacts that are stored in a database in the format of contact_id, forename, surname, address, telephone etc...
They are then exported to a CSV file, called up and asked a series of questions. So the result is a CSV file with contact_id, forname, surname, address, telephone, question 1 answer, question 2 answer.
I then want to import these contacts and their answers back into my database. This is the problem. I have a table named response which contains the contact_id, question_id, the response and the response date. So for each question a contact is asked a record will be entered into this table. E.g somebody is asked 5 questions, they will be recorded into the response table 5 times.
My problem is that I don’t know how I can get the CSV imported and then the columns for the questions to be recorded into the response table. I can easily get the CSV file into SQL and the contacts into a table but I am struggling to get the responses into the response table.
So for an example if I had a row in my CSV that looks like this:
544837, Mr, John, Smith, 1 Main Street, New Road, Nottingham, 01159443556, yes, no, maybe, yes, yes
I then want to get the last 5 columns into the response table but I need to know which question they said yes no or maybe to. The columns will have heading such as ARE_YOU_SINGLE and these will relate to a question reference in my question table which contains question_id, question_ref, question, created_date, last_modified.
Does anyone have any ideas how I might be able to do this? The question responses will always be in the same order in the CSV so it might be that they are just imported blindly but this doesn't seem like a very good idea.
Any help very much appreciated.
They are then exported to a CSV file, called up and asked a series of questions. So the result is a CSV file with contact_id, forname, surname, address, telephone, question 1 answer, question 2 answer.
I then want to import these contacts and their answers back into my database. This is the problem. I have a table named response which contains the contact_id, question_id, the response and the response date. So for each question a contact is asked a record will be entered into this table. E.g somebody is asked 5 questions, they will be recorded into the response table 5 times.
My problem is that I don’t know how I can get the CSV imported and then the columns for the questions to be recorded into the response table. I can easily get the CSV file into SQL and the contacts into a table but I am struggling to get the responses into the response table.
So for an example if I had a row in my CSV that looks like this:
544837, Mr, John, Smith, 1 Main Street, New Road, Nottingham, 01159443556, yes, no, maybe, yes, yes
I then want to get the last 5 columns into the response table but I need to know which question they said yes no or maybe to. The columns will have heading such as ARE_YOU_SINGLE and these will relate to a question reference in my question table which contains question_id, question_ref, question, created_date, last_modified.
Does anyone have any ideas how I might be able to do this? The question responses will always be in the same order in the CSV so it might be that they are just imported blindly but this doesn't seem like a very good idea.
Any help very much appreciated.