Reputation: 663
i have the following union query sql in my code
(SELECT TableA.ID, TableB.Group, '' as Name from TableA,TableB
where TableA.Ipfield=TableB.Androfield)
UNION (SELECT TableA.ID,'',TableC.Name where TableA.irgroup=TableC.iqgroup)
The problem is I need to export this sql as csv file, while i export as csv it should show the column names at begiining of file so i had used '' as Name in query1 so as to display Name as one column along with ID and Group. But the issue here is the column names are displayed properly but the datas are displayed twice , one with Name as '' and another with value for Name.
Name is a field in TableC and not in tableA and tableB. Is there any way i can display the datas only once with value for Name, I dont need the result with Name as '', it is just used to display the column name as Name along with ID and Group
Thanks Kindly Help!
Upvotes: 1
Views: 332
Reputation: 10517
just union one row with column names firts:
select 'ID' as ID, 'Group' as Group, 'Name' as Name from dual
union
(and here goes the rest of your query)
Upvotes: 2