Last post Mar 18, 2015 05:07 AM by Shawn - MSFT
Mar 13, 2015 07:27 AM|alexinio|LINK
I have a query that needs data from 3 different datasets.
Here's the code I have so far:
Dim Conn1 As New MySqlConnection(ConfigurationManager.ConnectionStrings("MYSQLConn1").ConnectionString)
Dim Conn2 As New MySqlConnection(ConfigurationManager.ConnectionStrings("MYSQLConn2").ConnectionString)
Dim query As String = "select distinct `number`from db1.numbers e where e.customer = 32"
Dim query2 As String = "select `number` from db2.numbers where CustomerID = 32"
Dim query3 As String = "select `number` from db2.numbers2"
DATASET1 = New MySqlCommand(query, Conn2).ExecuteReader
DATASET2 = New MySqlCommand(query2, Conn1).ExecuteReader
Results2 = New DataTable
DATASET3 = New MySqlCommand(query3, Conn1).ExecuteReader
Results = New DataTable
Results3 = New DataTable
Here's the query that I need it to work using the results from the above 3 datasets:
select distinct `number`
IF(`number` in (select `number` from DATASET2), 1, 0) as 'status'
from DATASET1 e
where number like '0744%'
and customer = 1
AND `number` not in (select `number` from DATASET3)
order by status desc;
Q: How can I make the above query work having these datasets?
Mar 18, 2015 05:07 AM|Shawn - MSFT|LINK
For this situation, I don't think you could achieve this by using sql query on the datasets.
You could try to use the temporary table in sql server to store the result filtered from the database table, then based on the temporary table, you could retrieve use the sql query to filter the final result you want.
For more information, you could refer to: