比方说,我有两张桌子
表格1:
code|name
121 ab
456 qw
Run Code Online (Sandbox Code Playgroud)
表2:
Kode_ak|Nama_ak
1 Bursa
2 Kustodian
3 Kliring
4 Assurance
5 Bunga
Run Code Online (Sandbox Code Playgroud)
我想把这两个表结合起来.结果将是这样的:
Kode_AK|Nama_ak |code|name
1 Bursa 121 ab
2 Kustodian 121 ab
3 Kliring 121 ab
4 Assurance 121 ab
5 Bunga 121 ab
1 Bursa 456 qw
2 Kustodian 456 qw
3 Kliring 456 qw
4 Assurance 456 qw
5 Bunga 456 qw
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我有这个代码:
public ActionResult RcColdis() {
string constr = @"Data Source=192.168.52.197,1433;Network Library=DBMSSOCN;Initial Catalog=DB_ADRIAN;User ID=adrian;Password=password;";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("select a.secCode, b.[Haircut (%)],c.[Absolute IDR (Miliar)] from openquery(PDC_MYAPPS,'select secCode from mii.secReq')a left join (select * from RC_Saham)b on a.secCode=b.kode left join (select * from Absolute_IDR)c on b.kode=c.[Kode Saham]where b.[Haircut (%)] is not null union select a.code_Ic,a. PERC_HRCT, case a. PERC_HRCT when 100 then 20 end from openquery(MANTARAY,'select b.code_ic, a.PERC_HRCT from cminstruments a, instrument_codes b where …Run Code Online (Sandbox Code Playgroud)