如何解决此错误?
此查询返回错误:查询(1241)错误:操作数应包含1列
SELECT uti_id, uti_nome FROM utilizador WHERE uti_escola=1 AND uti_id IN
(SELECT DISTINCT ens_utiid_escola, SQRT(POW(69.1 * (uti_latitude - ?), 2) + POW(69.1 * (? - uti_longitude) * COS(uti_latitude / 57.3), 2)) * 1.609344 AS distance
FROM utilizador LEFT OUTER JOIN ensino ON uti_id=ens_utiid WHERE uti_estado=1
AND uti_tipo=1 HAVING distance < ?) ORDER BY uti_nome
答案 0 :(得分:0)
错误来自查询的这一部分:
uti_id IN (SELECT DISTINCT ens_utiid_escola, SQRT(POW(69.1 * (uti_latitude - ?), 2) + POW(69.1 * (? - uti_longitude) * COS(uti_latitude / 57.3), 2)) * 1.609344 AS distance
首先,在select distinct
子查询中不需要in
。其次,错误是因为您有两行。因此,如果您想使用以下逻辑:
uti_id IN (SELECT ens_utiid_escola
FROM . . .
)
然后,您需要在distance
处重复表达式。