首页 > 解决方案 > Mysql在日期位于日期集中的条件下选择

问题描述

我的选择命令:

select * from wp_ved_currencies where date in (select DISTINCT date from wp_ved_currencies order by date desc limit 2);

错误信息:

Error
SQL query:Documentation


select * from wp_ved_currencies where date in (select distinct date from wp_ved_currencies order by date desc limit 2) LIMIT 0, 50
MySQL said:Documentation

#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

你能帮帮我吗?

标签: mysql

解决方案


您应该可以在此处加入限制子查询:

SELECT w1.*
FROM wp_ved_currencies w1
INNER JOIN
(
    SELECT DISTINCT date
    FROM wp_ved_currencies
    ORDER BY date DESC
    LIMIT 2
) w2
    ON w1.date = w2.date;

推荐阅读