Reputation: 313
I am using this query to create CSV of my mysql DB table
$path = getcwd() . '/uploads/data.csv' ;
$sql = "select email,username from `engine4_user` LIMIT 5000 into outfile '$path' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' ";
But now I need one extra field that is profile url .which doesn't exists on the table. So i wanna create a virtual url column using the ID of that user table. Like https://mysiteurl/profile/$user_id .
Please help. Thanks in advance.
Upvotes: 1
Views: 40
Reputation: 1109
Use "CONCAT" operator
$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' ";
Upvotes: 1