mysql - #1235 - 此版本的 MariaDB 尚不支持“LIMIT & IN/ALL/ANY/SOME 子查询”

当我尝试以下查询时出现此错误 SELECT pib FROM Firme_virmani WHERE id IN ( SELECT id_firme FROM narudzbine_virmani ORDER BY id DESC LIMIT 1) ORDER BY pib DESC LIMIT 1

回答1

加入子查询而不是使用 IN 运算符:

select pib
from firme_virmani
join (
    SELECT id_firme FROM narudzbine_virmani ORDER BY id DESC LIMIT 1
) ids on firme_virmani.id=ids.id_firme
order by pib desc
limit 1

https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=74d4361857768c43485b7faffe4e4507

相似文章