qFieldInner
PARAMETERS pText1 Text ( 255 );
SELECT entries.en_main, MIN(entries.en_id) AS en_id
FROM entries
WHERE (((entries.en_main) In (625, 1310)))
GROUP BY en_main;
当我运行此查询时,它返回:
625 76719
1310 177239
但是,如果我将其转换为:
PARAMETERS pText1 Text ( 255 );
SELECT entries.en_main, MIN(entries.en_id) AS en_id
FROM entries
WHERE (((entries.en_main) In (SELECT en_main FROM qFieldInnest)))
GROUP BY en_main;
然后它就会挂起。
qFieldInnest 是这个,当我手动运行时正确返回625和1310
PARAMETERS pText1 Text ( 255 );
SELECT DISTINCT entries.en_main
FROM entries
WHERE (((entries.en_lect) Like ("* " & [pText1] & "*") Or (entries.en_lect) Like ([pText1] & "*")) AND ((entries.en_ref)=0) AND (((entries.en_se)=1) OR ((entries.en_meros)=6))) OR (((entries.en_thama) Like ("* " & [pText1] & "*") Or (entries.en_thama) Like ([pText1] & "*")));
我无法理解这里出了什么问题。
答案 0 :(得分:3)
我会使用查询来处理此问题,该查询使用qFieldInnest
中的SQL作为子查询,并将INNER JOIN
子查询使用entries
表。
WHERE
中的qFieldInnest
条款让我难以理解。它也将挑战数据库引擎,因为它必须做多少工作。
我没有什么可以测试的,所以不确定我是否在下面的SQL中犯了错误。如果它不起作用,请将子查询SQL分解为新查询并单独测试。
PARAMETERS pText1 Text ( 255 );
SELECT e.en_main, MIN(e.en_id) AS en_id
FROM
entries AS e
INNER JOIN
(
SELECT DISTINCT en_main
FROM entries
WHERE
(
(
en_lect Like "* " & [pText1] & "*"
Or en_lect Like [pText1] & "*"
)
AND en_ref=0
AND
(
en_se=1
OR en_meros=6
)
)
OR
(
en_thama Like "* " & [pText1] & "*"
Or en_thama Like [pText1] & "*"
)
) AS sub
ON e.en_main = sub.en_main
GROUP BY e.en_main;