我需要这样的查询,它是使用 sqlbuilder Java 函数生成的:
SELECT Sum(est_hu) / Sum(
total_hu)
AS HU,
Max(year) AS YEAR
FROM b.counts BBCountsTable
WHERE ( BBCountsTable.bg IN
(SELECT DISTINCT
BBSubTable.c_id
FROM
b.block
BBSBlockSubTable
WHERE ( (
BBBlockSubTable.id IN ( 3 ) ) ) )) )
但是,当子查询生成时,它会像这样创建它:
SELECT Sum(est_hu) / Sum(
total_hu)
AS HU,
Max(year) AS YEAR
FROM b.counts BBCountsTable, b.block
BBSBlockSubTable
WHERE ( BBCountsTable.bg IN
(SELECT DISTINCT
BBSubTable.c_id
FROM
b.block
BBSBlockSubTable
WHERE ( (
BBBlockSubTable.id IN ( 3 ) ) ) )) )
它会自动附加子查询表名称,即 b.block BBSBlockSubTable,因此查询不起作用。任何克服这个问题的建议都会有很大帮助。