Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Exports Multiple MySQL Tables To CSV File

Posted on 2011-03-22
Medium Priority
Last Modified: 2012-05-11
I've found these queries...

So I'm trying to use left join etc to build a query to export multiple tables.

What I need to state every column from every table with the SELECT rather than using select all * ?

Just I'm having some issues getting it working and want to clear some things up so I'm not on an impossible path.

Thanks for your help
Question by:Ryan Bayne
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

tygrus2 earned 500 total points
ID: 35196276
If you join tables then the common index fields will be repeated & renamed for each occurance. Use the tablename.fieldname references to explicitly list the fields to SELECT.

SELECT Order.OrderID, OrderLine.ProductID, OrderLine.Qty
INTO OUTFILE '/tmp/orderitems.csv'
FROM Order LEFT JOIN OrderLine ON Order.OrderID=OrderLine.OrderID

Open in new window

Example is a bad choice for LEFT join but you get the idea.

Author Comment

by:Ryan Bayne
ID: 35197574
Yes so they would that had not entered my mind yet. This is for a Wordpress plugin. So I need to provide the user with a way to select the tables they want to export plus select the columns.

The problem I'm having must be syntax then because I've tried something like what your suggesting. At least I know I was on the right path that is all I wanted really, will just dump and execute some queries in the MySQL gui.

I must remember to check the users input for any duplicate index selections.

Thanks for clearing this up

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question