![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
Hi, I hope at least one of these newsgroups are still active. ![]() I'm trying to construct am MS Access (2007) query to insert multiple rows in a table. Actually, I have the data from a dump of a MySQL database. I'm trying the following syntax, but it fails for more than one row. INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) VALUES ('2010-08-14 11:39:14', '733997', 'Karsten75', 'Marauders', 8243, 1), ('2010-08-22 09:08:13', '734370', 'Sauffaus3', 'Resubmitted', 7619, 1), It works for a single row, but not for multiple rows. So I read up on the syntax and it seems the only way I can insert multiple rows into an Access table is if the data is already in another table? Surely I'm mistaken and there must be a way to insert multiple rows of data as an SQL query without having to code the INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) VALUES part of the query for each and every row? Thanks! |
#3
| |||||
| |||||
|
Hi, I hope at least one of these newsgroups are still active. ![]() I'm trying to construct am MS Access (2007) query to insert multiple rows in a table. Actually, I have the data from a dump of a MySQL database. |
|
I'm trying the following syntax, but it fails for more than one row. INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, |
|
`playCount`) VALUES ('2010-08-14 11:39:14' |
|
('2010-08-22 09:08:13', '734370', 'Sauffaus3', 'Resubmitted', 7619, 1), It works for a single row, but not for multiple rows. |
|
So I read up on the syntax and it seems the only way I can insert multiple rows into an Access table is if the data is already in another table? |
#4
| |||
| |||
|
|
On Fri, 15 Oct 2010 14:36:01 -0500, MikeB<mpbrede (AT) gmail (DOT) com> wrote: Hi, I hope at least one of these newsgroups are still active. ![]() I'm trying to construct am MS Access (2007) query to insert multiple rows in a table. Actually, I have the data from a dump of a MySQL database. snipped |
|
Not using the VALUES() syntax, no. You'll need a table. |

|
If they're coming from MySQL, why not just link to the MySQL table and use it as the source of the SELECT FROM? Or dump the MySQL data into a temp table? |
#5
| |||||
| |||||
|
|
MikeB wrote: Hi, I hope at least one of these newsgroups are still active. ![]() I'm trying to construct am MS Access (2007) query to insert multiple rows in a table. Actually, I have the data from a dump of a MySQL database. Why not link to the MySQL table and insert the data directly using insert...select? |
| I'm trying the following syntax, but it fails for more than one row. INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, What are those delimiters? Why are you even bothering to delimit these words? |
|
`playCount`) VALUES ('2010-08-14 11:39:14' You're inserting a date/time as text?? Is the destination a Jet table? |
|
, '733997', 'Karsten75', 'Marauders', 8243, 1), ('2010-08-22 09:08:13', '734370', 'Sauffaus3', 'Resubmitted', 7619, 1), It works for a single row, but not for multiple rows. Patient: It hurts when I raise my arm above my head Doctor: Well don't do that! |

| So I read up on the syntax and it seems the only way I can insert multiple rows into an Access table is if the data is already in another table? Pretty much, although there is a trick. There has to be a table that has at least a single row of data in it. it doesn't have to match the structure of the table into which you are inserting. The idea is to create a union query using that base table, using expressions for each column to be inserted: INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) SELECT TOP 1 #2010-08-14 11:39:14# As ts, '733997' As map, ... FROM basetable UNION ALL SELECT TOP 1 #2010-08-22 09:08:13# , '734370', ... FROM basetable |
#6
| |||
| |||
|
|
Well, the MySQL table was dumped on another person's system and sent to me as a file.... All that I have is this single .SQL file. Mike |
#7
| |||
| |||
|
|
On Fri, 15 Oct 2010 15:39:10 -0500, MikeB<mpbrede (AT) gmail (DOT) com> wrote: Well, the MySQL table was dumped on another person's system and sent to me as a file.... All that I have is this single .SQL file. Mike What's the format of the MySQL dump? Comma separated text strings? If so you can use File... Get External Data... Link, and select .txt as Files Of Type. Or you can Import the text file into a temp table. You might need to rename the file to use a .txt or .csv extension to get Access to recognize it, but if you have the data in computer readable form you can import it, one way or another! Could you post a (perhaps fake data but correct file format) example of a few records of the "dump" file? |
#8
| |||
| |||
|
|
John W. Vinson wrote: On Fri, 15 Oct 2010 15:39:10 -0500, MikeB<mpbrede (AT) gmail (DOT) com> wrote: Well, the MySQL table was dumped on another person's system and sent to me as a file.... All that I have is this single .SQL file. Mike What's the format of the MySQL dump? Comma separated text strings? If so you can use File... Get External Data... Link, and select .txt as Files Of Type. Or you can Import the text file into a temp table. You might need to rename the file to use a .txt or .csv extension to get Access to recognize it, but if you have the data in computer readable form you can import it, one way or another! Could you post a (perhaps fake data but correct file format) example of a few records of the "dump" file? THe data I posted above is in the exact format that it is in in the SQL file. Here's a bit of the "stuff before the actual data: |
#9
| |||
| |||
|
|
Bob Barrows wrote: INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) SELECT TOP 1 #2010-08-14 11:39:14# As ts, '733997' As map, ... FROM basetable UNION ALL SELECT TOP 1 #2010-08-22 09:08:13# , '734370', ... FROM basetable Pardon my utter ignorance, but may I ask why the "select top 1" appears in there twice? does that not simply select 1 row and that's it? |
#10
| |||
| |||
|
Hi, I hope at least one of these newsgroups are still active. ![]() I'm trying to construct am MS Access (2007) query to insert multiple rows in a table. Actually, I have the data from a dump of a MySQL database. I'm trying the following syntax, but it fails for more than one row. INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) VALUES ('2010-08-14 11:39:14', '733997', 'Karsten75', 'Marauders', 8243, 1), ('2010-08-22 09:08:13', '734370', 'Sauffaus3', 'Resubmitted', 7619, 1), It works for a single row, but not for multiple rows. So I read up on the syntax and it seems the only way I can insert multiple rows into an Access table is if the data is already in another table? Surely I'm mistaken and there must be a way to insert multiple rows of data as an SQL query without having to code the INSERT INTO `scoresUncharted` (`ts`, `map`, `user`, `group`, `score`, `playCount`) VALUES part of the query for each and every row? Thanks! |
![]() |
| Thread Tools | |
| Display Modes | |
| |