Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:03:17+00:00 2026-06-07T14:03:17+00:00

I have a MySQL db which needs to be exported to a CSV file.

  • 0

I have a MySQL db which needs to be exported to a CSV file. Google told me about a lot of examples for doing this, but all the examples are for exporting just a single table.

Could anyone please help with exporting some data in a particular way (given below)?

The database is like this:

artist

  • id
  • name

album

  • id
  • name

title

  • id
  • artist_id <- FK
  • album_id <- FK
  • name

title has FK fields which point to artist name and album name.

How can do the export so that the output csv file looks like this:


column1 (artist), column2 (album), column3 (title)


John, The Latest, First Song
John, Work in progress, Nice song
John, California, Oh SF
Luke, My Songs, One Song
Luke, My Songs, Two Song
Luke, Collected Works, Magnum Opus
Tom, My works, I song
Tom, My works, II song
Tom, My works, III song

TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:03:19+00:00Added an answer on June 7, 2026 at 2:03 pm

    You can create a VIEW and export from there.

    Extending Mahesh’s query:

    CREATE VIEW view_example AS 
    SELECT artist.name AS artist_name, album.name AS album_name , title.name AS title_name 
    FROM artist,album,title 
    WHERE artist.id=title.artist_id AND album.id=title.album_id;
    
    SELECT * FROM view_example INTO OUTFILE 'example_output.csv' FIELDS TERMINATED BY ',';
    

    I tested this and it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL file which I want to import via PHP 5. In
I have a big mysql query which needs to trawl through 4 tables to
We have a simple sql script which needs to be executed against a MySQL
I have a MYSQL database which needs to be accessed by both PHP and
I have MySQL query which I think needs a subquery. I'd like to count
I have a MySQL insert query which needs to pull one data field from
I've Googled this topic a lot, but cannot find a solution which fits my
I have some code which needs to ensure some data is in a mysql
I'm not very familiar in programming databases, but I have a Mysql-Database which I
I am designing a MySQL database which needs to handle about 600 row inserts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.