Sourceminer
asked on
Insert single value set into multiple rows
I am not sure how to ask this question and it might be basic but I have a single set of values
"Date & Time","Computer","IP Address","MAC Address","Folder Or Server IP","Packet Length","Write Speed","Read Speed","Notes"
"10-18-2011 at 09:42:49","DCX","10.10.10. 142","00-0 0-00-00-58 -00","serv er","1,000 ,000 × 1","6.4770640 Mbps","2.5086320 Mbps",""
I need to insert these values into MySql where a Table exists but each value would be a separate insert statement.
"Date & Time","Computer","IP Address","MAC Address","Folder Or Server IP","Packet Length","Write Speed","Read Speed","Notes"
"10-18-2011 at 09:42:49","DCX","10.10.10.
I need to insert these values into MySql where a Table exists but each value would be a separate insert statement.
I am not sure why you want multiple insert statements for this...simple insert
INSERT INTO table_name (col_name1,col_name2,...,c ol_name10) VALUES (value1,value2,...,value10 )
if just one per insert then,,
INSERT INTO table_name (col_name1) VALUES (value1)
INSERT INTO table_name (col_name1,col_name2,...,c
if just one per insert then,,
INSERT INTO table_name (col_name1) VALUES (value1)
I agree. I figure it might be an entity-attribute-value table, which is why I asked for structure as that would impact how the final solution is actual derived as typically those require the same entity id for all rows, which needs to be gathered from the insert of the entity itself.
ASKER
Sorry as I was writing Its hard to put into words, (thanks for the fast response too)
Let me try again,
The destination table contains 3 Fields
ID, ExtraFieldID, Value
The Command I run exports a log of data in CSV format (as outlined above)
I am really only looking for the 2 values to be inserted into the destination table
,"6.4770640 Mbps","2.5086320 Mbps",
However they need to individually be inserted
IE: Insert into tablename SET ID=AUTO, ExtraFieldID=533, Value=(one of the 2 items)
Followed by another insert with the second value.
Thinking it might need to be inserted as a temp table?
Let me try again,
The destination table contains 3 Fields
ID, ExtraFieldID, Value
The Command I run exports a log of data in CSV format (as outlined above)
I am really only looking for the 2 values to be inserted into the destination table
,"6.4770640 Mbps","2.5086320 Mbps",
However they need to individually be inserted
IE: Insert into tablename SET ID=AUTO, ExtraFieldID=533, Value=(one of the 2 items)
Followed by another insert with the second value.
Thinking it might need to be inserted as a temp table?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ended up taking this to a developer.
Remember, you can INSERT multiple rows like:
INSERT INTO tablename(<column list>)
SELECT <column list> UNION ALL
SELECT <column list>;
Or:
INSERT INTO tablename(<column list>)
VALUES(<value list>);
INSERT INTO tablename(<column list>)
VALUES(<value list>);
Or:
INSERT INTO tablename(<column list>)
VALUES(<value list>), (<value list>);
But it really depends on your exact output need and source of the data being inserted.