|
我正在尝试inner join使用视图和表格通过以下查询8 W! D7 ^( b) w' ]4 j
SELECT AcId,AcName,PldepPer,RepId,CustCatg,HardCode,BlockCust,CrPeriod,CrLimit, BillLimit,Mode,PNotes,gtab82.memno FROM VCustomer INNER JOIN vcustomer AS v1 ON gtab82.memacid = v1.acid WHERE (AcGrCode = '204' OR CreDebt = 'True') AND Masked = 'false'ORDER BY AcName错误是
9 A6 T- M3 I9 i$ umissing FROM-clause entry for table "gtab82" " [- w3 J& [/ l' K0 b
解决方案:
( \! R1 O8 L% S. h SELECT
$ [8 y' [1 h T' W/ V- l, | AcId,AcName,PldepPer,RepId,CustCatg,HardCode,BlockCust,CrPeriod,CrLimit,; @0 \# e6 Z* {. p
BillLimit,Mode,PNotes,gtab82.memno 7 c% _$ X: u# [5 N' h" u& J' h
FROM/ p1 X7 B- A& p9 |9 R
VCustomer AS v1* p9 T7 D) H8 z
INNER JOIN ) }5 \. y& O1 j f+ J' P
gtab82 ON gtab82.memacid = v1.AcId
1 V2 _5 x7 z8 Y3 u1 c/ R WHERE (AcGrCode = ‘204’ OR CreDebt = ‘True’)
7 Z% p6 c; y. L4 @6 I AND Masked = ‘false’8 K+ d" f# a, G
ORDER BY AcName
- P' |0 k" b( c3 t! K+ ?' u由于连接表中的列重复且表名长或表本身连接,通常只需在表名前添加列名作为表名的别名。在你的情况下,你会用别名,VCustomer但ON由于不确定性,只在子句中使用。您可能需要查看代码的这方面。 |
|