“Unknown column in 'field list'”, but column does exist

后端 未结 9 1403
既然无缘
既然无缘 2020-12-06 04:41
DROP TABLE IF EXISTS `transactions`;
CREATE TABLE `transactions` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `purchase_date` datetime DEFAULT NULL,
  PRIMAR         


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 05:21

    This might not help anyone else, but adding this "just in case" it helps someone.

    In my situation it was a different solution.

    I receive large datasets as Excel CSV files and use a (WIL) script to convert the .csv file into an importable .sql file. I had an error in my script whereby these two lines did not reference the same table name (I had hard-coded the first location and forgot to update it):

    * "INSERT INTO `old_table_name` (`cid`, `date`, etc etc"
    * "CREATE TABLE IF NOT EXISTS `":_dbName:"` (etc etc "
    

    I just changed the first line to also get the table name from the variable, and voila!

    * "INSERT INTO `":_dbName:"` (`cid`, `date`, etc etc"
    

    So check those two lines in your import SQL file.

提交回复
热议问题