我有两个查询。一个来自一个数据库,一个来自另一个。
第二个查询使用第一个查询的数据作为表。(这是我需要知道怎么做)
查询比示例更复杂,但我试图使其简单。下面的例子:
DataTable dt = new DataTable();
OdbcConnection myConnection = salesConnection();
myConnection.Open();
OdbcCommand selectCMD = new OdbcCommand("SELECT CUSTOMER.CUSTOMER_NBR " +
"FROM CUSTOMER", myConnection);
OdbcDataAdapter cmd = new OdbcDataAdapter();
cmd.SelectCommand = selectCMD;
cmd.Fill(dt);
myConnection.Close();
DataTable dtM = new DataTable();
myConnection = mConnection();
myConnection.Open();
selectCMD = new OdbcCommand("SELECT '**DATA TABLE ABOVE**'.CUSTOMER_NBR " +
"FROM '**HOW TO I REFERENCE THE DATA TABLE ABOVE**'",
myConnection);
cmd = new OdbcDataAdapter();
cmd.SelectCommand = selectCMD;
cmd.Fill(dtM);
myConnection.Close();