export mysql list of tables from mysql to csv file using php

后端 未结 4 1754
刺人心
刺人心 2021-01-03 15:36

I wonder if someone could actually show me a sample PHP code on how can i export around 50 tables in a MySQL database to a CSV file. My database name is \"samples\" and i ha

4条回答
  •  孤街浪徒
    2021-01-03 16:31

    This is how to export 1 table directly from mysql terminal. I've just used the tmp directory as an example buy you can change the path to anything you like:

    select * from product where condition1 order by condition2 desc INTO OUTFILE   '/tmp/myfile.csv' FIELDS    TERMINATED BY ',' ESCAPED BY '\\' OPTIONALLY ENCLOSED BY '"';
    

    or with php and mysqli:

提交回复
热议问题