Question: i have a powershell script with 2 export-csv to the same file.

But the second export-csv overwrite the previous csv file.

I don't want this.

For the second export-csv, i want write the result to the B column in excel, so i want to export in the same csv file, but to the second column.

The $dataSet.Tables["Query1"] return : 

```
COLUMN1
232

```

The $dataSet.Tables["Query2"] return :

```
COLUMN2
289

```

How to do this?

There is my script : 

```
$mysql = New-Object MySql.Data.MySqlClient.MySqlConnection("server=$serv;port=$port;uid=$user;pwd=$password;database=$db;Pooling=False")
$mysql.Open()

$sqlquery1 = Get-Content "C:\query1.txt"
$sqlquery2 = Get-Content "C:\query2.txt"

$req = New-Object Mysql.Data.MysqlClient.MySqlCommand($sqlquery1,$mysql)
$dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($req)
$dataSet = New-Object System.Data.DataSet
$dataAdapter.Fill($dataSet, "Query1") | Out-Null
$dataSet.Tables["Query1"] | Export-Csv -path "C:\result.csv" -NoTypeInformation

$req2 = New-Object Mysql.Data.MysqlClient.MySqlCommand($sqlquery2,$mysql)
$dataAdapter2 = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($req2)
$dataSet = New-Object System.Data.DataSet
$dataAdapter2.Fill($dataSet, "Query2")  | Out-Null

$dataSet.Tables["Query2"] | Export-Csv -path "C:\result.csv" -NoTypeInformation

$mysql.Close()

```

Thank you

Answer: 
This is how i resolved it 

```
$mysql = New-Object MySql.Data.MySqlClient.MySqlConnection("server=$serv;port=$port;uid=$user;pwd=$password;database=$db;Pooling=False")
$mysql.Open()

$sqlquery1 = Get-Content "C:\query1.txt"
$sqlquery2 = Get-Content "C:\query2.txt"

$req = New-Object Mysql.Data.MysqlClient.MySqlCommand($sqlquery1,$mysql)
$dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($req)
$dataSet = New-Object System.Data.DataSet
$dataAdapter.Fill($dataSet, "Query1") | Out-Null
$processrequest1 =  ($dataSet1.Tables["Query1"] | Format-Table -HideTableHeaders) | Out-String
$resultrequest1 = [int]$processrequest1

$req2 = New-Object Mysql.Data.MysqlClient.MySqlCommand($sqlquery2,$mysql)
$dataAdapter2 = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($req2)
$dataSet = New-Object System.Data.DataSet
$dataAdapter2.Fill($dataSet, "Query2")  | Out-Null
$processrequest2 =  ($dataSet1.Tables["Query2"] | Format-Table -HideTableHeaders) | Out-String
$resultrequest2 = [int]$processrequest2

$array1 = @() 
$array1 += New-Object psobject -Property @{Column1=$resultrequest1;Column2=$resultrequest2}
$array1 |  Export-Csv -path "C:\result.csv" -NoTypeInformation -Delimiter ";"

$mysql.Close()

```
Simple answer: You don't. Your queries returns different headers. 

If they are the same value but different column names you should convert the result from the second query to objects with the same property name as the first( column1 ) and save the results from both queries in an array that you export when both are done.