• noy2014 (7/12/2014)


    I am new to php and sql, but learning fast. I'm trying to understand the behavior of the db when importing data files using phpMyAdmin. Here is what I'm currently doing, and I'd like to know if I'm taking the best (and only) approach, or should be handling it differently.

    1) I export a CVS file from one source, which includes dates and (comma separated) numbers, both in string format (which I need to convert to 'date' and 'int' format).

    2) After I import the file into the db, I then add more columns to the end of the table, which I use to convert string to date, and string to integer.

    My issues start at this point

    3) The next time I import data from the same source, the number of columns don't match up, so I get an error. I had hoped that since new columns are on the end, then the import would just ignore any lack of data, but no. To get around this, I have been manually adding the same # of commas, to match the # of new columns, to each row in the new data file. This seems like a ridiculous approach. Is it possible to import data linearly, or have it ignore importing values for certain columns?

    4) Then the new data includes both NEW records and UPDATES to existing records. So it is possible to have the import do both (a) add the new records, while (b) update records with matching primary key?? Otherwise, I find myself deleting the entire db, and importing the new one (which has other nuisances).

    I may be mistaken as I have never used PHPMyAdmin but I think you are referring to working with MySql as opposed to the SQL Server Platform...

    If this is so, then you're better off asking your question on a MySql Forum as this is a SQL Server one.