Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

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-00-00-00-58-00","server","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.
0
Sourceminer
Asked:
Sourceminer
  • 3
  • 2
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
Just for clarity, what should the final data in the table look like (i.e., post the destination table structure and expected rows after the above INSERT is complete).

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.
0
 
PranjalShahCommented:
I am not sure why you want multiple insert statements for this...simple insert

INSERT INTO table_name (col_name1,col_name2,...,col_name10) VALUES (value1,value2,...,value10)

if just one per insert then,,

INSERT INTO table_name (col_name1) VALUES (value1)
0
 
Kevin CrossChief Technology OfficerCommented:
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.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
SourceminerAuthor Commented:
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?

0
 
Kevin CrossChief Technology OfficerCommented:
This may be helpful:
http://www.experts-exchange.com/Database/MySQL/A_3622-A-MySQL-Tidbit-In-line-CSV-Parsing.html

It has links to non-XML options. Additionally, you will see how to load the CSV in the first place using LOAD DATA INFILE. Using this method, you can insert both values at once with the INSERT INTO ... SELECT method I showed earlier.
0
 
SourceminerAuthor Commented:
Ended up taking this to a developer.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now