Check out example codes for "mysql query result to file". It will help you in understanding the concepts better.

Code Example 1

mysql -user -pass -e "select cols from table where cols not null" > /tmp/output

Learn ReactJs, React Native from akashmittal.com