0

nohup mysql -uroot drdb -e "select c_imei as IMEI, c_last_seen_imsi as IMSI, c_msisdn as MSISDN from tb_e A, tb_m B where A.c_last_seen_imsi=B.c_imsi into outfile '/apps/duinfo.txt';" &

In the above command, I can see the out file generated. But the column name is not specified. How do I specify column name for the out file?

NB: The answer to the question "Include headers when using SELECT INTO OUTFILE?" didn't resolve my issue.

Sachin Aravind
  • 150
  • 1
  • 2
  • 11

1 Answers1

0

Sometimes the column name may not appear on top due to order of the resultset, so try creating a dummy column and order the output against it for a consistent result. Try the query below instead


 SELECT IMEI,IMSI,MSISDN FROM
  (select '1' as dummy_col, 'IMEI'as IMEI, 'IMSI' as IMSI, 'MSISDN' as MSISDN
  UNION ALL
  select '2' as dummy_col, c_imei as IMEI, c_last_seen_imsi as IMSI, c_msisdn as MSISDN from tb_e A, tb_m B where A.c_last_seen_imsi=B.c_imsi) ORDER BY dummy_col