Home > Back-end >  ClientDataSet1 SQL table associated himself an error? A great god, please give directions
ClientDataSet1 SQL table associated himself an error? A great god, please give directions

Time:11-03

Create a customer table, table a field is introduced, this paper introduces itself is also records of customer list
No problem in SQL query execution:
Select the CLI BC_ID, CLI BC_Number, CLI. BC_FULLNAME, CLI. BC_DZ, CLI. BC_DH, CLI. BC_LXR, isnull (BG) G_Name, ' ') as BC_CPFL,
CLI BC_LXRDH, CLI BC_FZR, CLI. BC_FZRDH,
Isnull (BL) BCL_Name, ' ') as BC_KHJB, CLI. BC_ZJSSL, isnull (DQ) BDQ_Name, ' ') as BC_KHDQ,
Isnull (PQ) BCR_Name, ' ') as BC_KHPQ, isnull (bc2 BC_FULLNAME, ' ') as BC_JSZ,
Isnull (be1 E_Name, ' ') as BC_SCKF, isnull (BBM BBM_Name, ' ') as BC_SHBM, CLI. BC_JYFW, CLI. BC_QTSM,
CLI BC_HZRQ, CLI. BC_JDRQ from B_CLIENTS AS CLI
Left the join B_Goods as BG on G_ID=BC_CPFL
Left the join B_Clients_Level as BL on BCL_ID=BC_KHJB
Left the join B_Clients_DQ as DQ on BDQ_ID=BC_KHDQ
Left the join B_Clients_Region as PQ on BCR_ID=BC_KHPQ
Left the join B_CLIENTS as bc2 on bc2. BC_ID=cli. Bc_jsz
Left the join B_Employee as BE1 on BE1. E_ID=CLI. BC_SCKF
Left the join B_Clients_BM as BBM on BBM_ID=CLI. BC_SHBM
Where the CLI. BC_DELETED=0

In the DELPHI three-tier
SQL:='select CLI BC_ID, CLI BC_Number, CLI. BC_FULLNAME, CLI. BC_DZ, CLI. BC_DH, CLI. BC_LXR, isnull (BG) G_Name,' ' ' ') as BC_CPFL, ';
SQL: SQL +='CLI BC_LXRDH, CLI. BC_FZR, CLI BC_FZRDH,';
SQL: SQL +='isnull (BL) BCL_Name,' ' ' ') as BC_KHJB, CLI. BC_ZJSSL, isnull (DQ) BDQ_Name, ' ' ' ') as BC_KHDQ, ';
SQL: SQL +='isnull (PQ) BCR_Name,' ' ' ') as BC_KHPQ, isnull (bc2 BC_FULLNAME, ' ' ' ') as BC_JSZ, ';
SQL: SQL +='isnull (be1 E_Name,' ' ' ') as BC_SCKF, isnull (BBM BBM_Name, ' ' ' ') as BC_SHBM, CLI. BC_JYFW, CLI. BC_QTSM, ';
SQL: SQL +='CLI. BC_HZRQ, CLI BC_JDRQ from B_CLIENTS AS CLI';
SQL: SQL +='left join B_Goods as BG on G_ID=BC_CPFL';
SQL: SQL +='left join B_Clients_Level as BL on BCL_ID=BC_KHJB';
SQL: SQL +='left join B_Clients_DQ as DQ on BDQ_ID=BC_KHDQ';
SQL: SQL +='left join B_Clients_Region as PQ on BCR_ID=BC_KHPQ';

SQL: SQL +='left join B_CLIENTS as bc2 on bc2. BC_ID=(. Select a2 BC_ID from B_CLIENTS as a2 where a2. BC_ID=cli. Bc_jsz)';
SQL: SQL +='left join B_Employee as BE1 on BE1. E_ID=CLI. BC_SCKF';
SQL: SQL +='left join B_Clients_BM as BBM on BBM_ID=CLI. BC_SHBM';
SQL: SQL +='where CLI. BC_DELETED=0;
ClientModule1. ClientDataSet1. Close;
ClientModule1.ClientDataSet1.Com mandText:=SQL;
ClientModule1. ClientDataSet1. Open;

Execution time: prompt:
Remote error: [FireDAC] [Phys] [ODBC] [Microsoft] [10.0] SQL Server Native Client/SQL Server cannot bind multi-part identifier "cli. Bc_jsz
"
Excuse me, is what went wrong?

CodePudding user response:

Brother, I suggest you use TStrings to write SQL code, like you write check up is very painful, I at ordinary times my writing so
VSQL. Add (' b.X the select a.X XX, XX, c.Y YY ');
VSQL. Add (' the from tbTable1 a ');
VSQL. Add (' left join tbTable2 on Amy polumbo KID b=p. KID ');
VSQL. Add (' left join tbTable3 c on b. KID=c.F KID ');
VSQL. Add (Format (' where a. c_jsz=', '% s'' ', [sKey]));

Does it clear the many like this?

CodePudding user response:

(select a2. BC_ID from B_Clients as a2 where a2. BC_ID=cli. Bc_jsz) ';

Here is the subquery, don't know of the definition of external cli. Bc_jsz
  • Related