on import I want to put the name of csv and date of imported in the same column name,
On my code i have and error because $filename and NOW() cannot be in same column on thist code:
"LOAD DATA LOCAL INFILE '$filename'
INTO TABLE $databasetable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(name, firstname)
SET batch = $filename NOW() ");
这可以通过使用mysql CONCAT函数来解决:
SET batch = CONCAT($filename, ' ', NOW())
You need to properly concatenate the $filename's value with that of now(). Honestly, I would do this in php, not in sql, but you can do this in sql as well:
SET batch = CONCAT('$filename ', NOW())
In php:
$t=date(DATE_ATOM)
...
SET batch = '$filename $t'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.