SOFTELメモ

Softel Inc.

【SQL】歯抜け見つかる?

set @primary_key = 1;
select
@primary_key := @primary_key + 1 AS new_primary_key,
CASE WHEN m.id = @primary_key
THEN 1
ELSE 0
END AS confirm_key
from m
where m.id >= 2
group by m.id
having confirm_key = 0
order by m.id
limit 0,1;

関連するメモ

コメント