1

私はmysqlを使用しています。ここに私のSQLがあります

select *
from releases
where  id >
(
    select min(id) as x
    from releases 
    where released > "2011-12-01"
) 
limit 0,30 

これは正しいです。しかし、次のように id が範囲内 (より大きいだけでなく) にあるアイテムを見つけたい:

select *
from releases
where  id >
    ((
        select min(id) as x , max(id) as y
        from releases 
        where released > "2011-12-01"
    ) as D ) D.x and id < D.y
limit 0,30 
4

2 に答える 2

1

私はこのようにします:

select 
    *
from 
    releases,
    (select 
        min(id) as x, 
        max(id) as y
     from
        releases
     where released > "2011-12-01"
     ) as D   
where
    id between D.x and D.y
limit 0,30
于 2012-11-08T07:40:12.547 に答える
0

これを試して:

SELECT r.* 
FROM releases r 
JOIN (SELECT MIN(id) minId, MAX(id) maxId FROM releases WHERE released > '2011-12-01') AS A ON r.id BETWEEN A.minId AND A.maxId 
LIMIT 0,30;
于 2012-11-08T07:47:32.753 に答える