Generate CSV based on MySQL query from phpMyAdmin

前端 未结 4 1205
感情败类
感情败类 2020-12-16 09:48

Can I generate a CSV file from phpMyAdmin based on a MySQL query?

For example, let\'s say I queried a table to return results for the word \"image\". Could I then p

相关标签:
4条回答
  • 2020-12-16 09:49
    create table tmp_export
    SELECT * from table_name WHERE column_name .....
    

    It created a table and then I exported the table as CSV. This solution worked fine for me.

    0 讨论(0)
  • 2020-12-16 10:02

    In PhpMyAdmin, go into the SQL tab and enter your query in there. Hit go, then click Export at the bottom of your results. You can select to export as a CSV.

    In case you're interested, here's how to do it via SQL without PMA: How to output MySQL query results in CSV format?

    0 讨论(0)
  • 2020-12-16 10:11

    You may be able to use the SELECT ... INTO OUTFILE... functionality. Although this will place the CSV file on the server. That's a long page, because it's the page for the whole "Select" syntax, but the basics are below:

    SELECT col1,col2,col3 INTO OUTFILE '/tmp/result.txt'
      FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
      LINES TERMINATED BY '\n'
      FROM MyTable;
    
    0 讨论(0)
  • 2020-12-16 10:11

    What also works well is creating a table with the query and then export the table as usual, having all the options of phpmyadmin export available. Simply do something like this in SQL box of phpmyadmin

    create table tmp_export
    select * from xxxx
    

    No problems with complex queries and large datasets using this approach.

    0 讨论(0)
提交回复
热议问题