我正在尝试使用inner join
视图和使用以下查询的表
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
,错误是
missing FROM-clause entry for table "gtab82"
答案 0 :(得分:24)
SELECT
AcId, AcName, PldepPer, RepId, CustCatg, HardCode, BlockCust, CrPeriod, CrLimit,
BillLimit, Mode, PNotes, gtab82.memno
FROM
VCustomer AS v1
INNER JOIN
gtab82 ON gtab82.memacid = v1.AcId
WHERE (AcGrCode = '204' OR CreDebt = 'True')
AND Masked = 'false'
ORDER BY AcName
由于连接表中的列名重复且表名为long或表连接到自身,因此在需要使用表名称为列添加前缀时,通常只使用表名的别名。在您的情况下,您使用VCustomer
的别名,但仅出于不确定的原因仅在ON
子句中使用它。您可能希望查看代码的这一方面。
答案 1 :(得分:9)
因为gtab82表不在FROM或JOIN子句中。在这些情况下,您可以引用gtab82表:gtab82.memno和gtab82.memacid