mysql-logo
MYSQLDUMP เป็นโปรแกรมที่เอาไว้ใช้ในการ export data จาก MySQL database ซึ่งโดยการใช้งานทั่วไปแล้วนิยมนำ MYSQLDUMP มาใช้ในการ export ข้อมูลออกมาหมดทั้งหมด (table หรือ database) แต่ถ้าหากต้องการ export ข้อมูลบางส่วนออกมาด้วยการใช้ where ก็สามารถทำได้เช่นกัน โดยให้ใช้ option –where แล้วตามด้วยเงื่อนไขต่างๆ ดังตัวอย่างด้านล่างนี้

export ข้อมูลเป็น SQL format

$ mysqldump -uUserName -pYourPassword --databases DATABASE_NAME --tables TABLE_NAME --where='Where cluase conditions' -u root -pYOUR_PASSWORD > data.sql

export ข้อมูลเป็น csv format

$ mysqldump -uUserName -pYourPassword --databases DATABASE_NAME --tables TABLE_NAME --where='Where cluase conditions' -u root -pYOUR_PASSWORD --fields-enclosed-by=\" --fields-terminated-by=, > data.csv