我正在使用此查询创建我的mysql数据库表的CSV
$path = getcwd() . '/uploads/data.csv' ;
$sql = "select email,username from `engine4_user` LIMIT 5000 into outfile '$path' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' ";
但是现在我需要一个额外的字段,它是配置文件url。它不存在于表中。所以我想使用该用户表的ID创建一个虚拟URL列。像https://mysiteurl/profile/ $ user_id。
请帮忙。提前谢谢。
答案 0 :(得分:1)
使用“CONCAT”运算符
$sql = "SELECT
email,
username,
CONCAT('https://mysiteurl/profile/',user_id) as profile_url
FROM `engine4_user`
LIMIT 5000
into outfile '$path' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' ";