Say, we have the following Student table:
Name Roll Dept
demo1 123 CSE
demo2 124 CSE
demo3 125 EEE
demo4 126 ECE
demo5 127 EEE
demo6 128 ETE
demo7 129 ETE
I want to execute a sql query on the above table such that the students of the table will be grouped into departments and each group result will be stored in a separate excel file. For example:
Excel file 1 may contain:
Name Roll Dept
demo1 123 CSE
demo2 124 CSE
Excel file 2 may contain:
Name Roll Dept
demo3 125 EEE
demo5 127 EEE
..... and so on.
The following query can group the students:
select Name, Roll, Dept from Student
group by Dept;
But how can I store the group wise results into different files? I am using mySQL.