I’m trying to import a text file into a MySQL database, and I’m having trouble getting the first field (card_no) to populate completely in all of my records. After I import the file (which does not produce any errors), the first record shows up correctly but the other records do not. Can anyone tell me how I can remedy this? — And in case it matters, I was using phpMyAdmin to load the file. — Thanks for your time.
Here’s the structure of the database:
Field Type Collation Attributes Null
card_no smallint(6) Yes NULL
name varchar(100) latin1_swedish_ci No
artist varchar(30) latin1_swedish_ci Yes NULL
color varchar(25) latin1_swedish_ci Yes NULL
rarity varchar(1) latin1_swedish_ci Yes NULL
expansion varchar(50) latin1_swedish_ci Yes NULL
Here’s the code:
LOAD DATA LOCAL INFILE 'C:\\xampp\\tmp\\php43.tmp'
INTO TABLE `mtginfo` FIELDS TERMINATED BY ';'
ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY ',';
Here’s the imported file:
"1";"Ajani Goldmane";"Aleksi Briclot";"White";"M";"Magic 2010",
"2";"Angel's Mercy";"Andrew Robinson";"White";"C";"Magic 2010",
"3";"Armored Ascension";"Jesper Ejsing";"White";"U";"Magic 2010",
"4";"Baneslayer Angel";"Greg Staples";"White";"M";"Magic 2010",
"5";"Blinding Mage";"Eric Deschamps";"White";"C";"Magic 2010"
Here’s a sample of the output:
card_no name artist color rarity expansion
1 Ajani Goldmane Aleksi Briclot White M Magic 2010
0 Angel's Mercy Andrew Robinson White C Magic 2010
0 Armored Ascensi Jesper Ejsing White U Magic 2010
0 Baneslayer Ange Greg Staples White M Magic 2010
0 Blinding Mage Eric Deschamps White C Magic 2010
I’m not sure what the protocol is for answering your own question, so in case anyone else has this issue I’ll post the solution I just discovered. — I have the CARD_NO field type as smallint, and I’m trying to load a non-integer type into it. Hence the import does not load the char type (char because of the quotes), and it moves to the next field. — Thanks again for the answer Devart. While your response didn’t correct my issue, it did get me to think about my problem so more.