SELECT GROUP_CONCAT(CONCAT("'",COLUMN_NAME,"'"))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tmp3'
ORDER BY ordinal_position;
SELECT 'appln_id',
'docdb_family_id',
'filing_year',
'appln_title',
'GRANTED',
'doc_std_name',
'doc_std_name_id',
'person_ctry_code',
'applt_seq_nr',
'invt_seq_nr',
'earliest_filing_year',
'priority',
'person_address_id',
'company_name',
'firm_id',
'person_state',
'person_country',
'person_lat',
'person_lng',
'clean_person_address',
'country',
'capital',
'firm_id2',
'hq_state',
'hq_country',
'hq_lat',
'hq_lng',
'hq_address'
UNION ALL
SELECT DISTINCT *
FROM tmp3
WHERE firm_id2 = 383
ORDER BY earliest_filing_year,
docdb_family_id,
applt_seq_nr,
invt_seq_nr
INTO OUTFILE '/tmp/schott_solar.txt';