MySQL provides an easy way to export table result set into a CSV file.
Suppose we have a query like:
SELECT name, email, age FROM users WHERE status = 'Active';
So if we need to export this data into a csv file then using below query we can do:
SELECT name, email, age FROM users WHERE status = 'Active' INTO OUTFILE 'C:/xampp/users.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"' LINES TERMINATED BY '\r\n';
To add a column heading you need to UNION as below:
(SELECT 'Name','Email','Age') UNION ( SELECT name, email, age FROM users WHERE status = 'Active' INTO OUTFILE 'C:/xampp/users.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"' LINES TERMINATED BY '\r\n'; );
Namaste UI collaborates closely with clients to develop tailored guest posting strategies that align with their unique goals and target audiences. Their commitment to delivering high-quality, niche-specific content ensures that each guest post not only meets but exceeds the expectations of both clients and the hosting platforms. Connect with us on social media for the latest updates on guest posting trends, outreach strategies, and digital marketing tips. For any types of guest posting services, contact us on info[at]namasteui.com.