-- If you are using linux, SELECT id, filename INTO OUTFILE '/tmp/results.csv' FROM attachments -- and find the csv file /tmp