Separate Exports from a MYSQL query
I would like to create separate expor开发者_StackOverflowted reports for the different types of animal I have in my table. I can write these reports separately, however I have over 200 different animal types and therefore running 200 separate queries is impractical.
ANIMAL_TABLE
AnimalName
-----------
CAT
DOG
MOUSE
HORSE
I basically would like to run a similar query to
SELECT * INTO OUTFILE '/tmp/ANIMAL-NAME.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ‘\\’
LINES TERMINATED BY '\n'
FROM ANIMAL_TABLE WHERE 1
but have 4 CSV files instead of one, effectively every change in animal type creates a new file
CAT.csv
DOG.csv
MOUSE.csv
HORSE.csv
Any help would be appreciated.
SELECT * INTO OUTFILE '/tmp/ANIMAL-HORSE.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ‘\\’
LINES TERMINATED BY '\n'
FROM ANIMAL_TABLE WHERE animal_name LIKE 'horse'
精彩评论