Content

  Title: query01

set @sname = 'm2'; set @pst = 200; set @ext = 50; ((select res.id as ID, res.eng as English, @ini as Init, @pst as Past, @ext as Extend from (select max(s.id) as id, s.voca_eng as eng from sources s, (select @ini := min(s.id) from sources s where s.source_name collate utf8mb4_unicode_ci = @sname) as var where s.id between @ini and @ini + @pst + @ext - 1 group by s.voca_eng order by ID) as res where res.id < @ini + @pst) order by rand() limit 5) union ((select res.id as ID, res.eng as English, @ini as Init, @pst as Past, @ext as Extend from (select max(s.id) as id, s.voca_eng as eng from sources s where s.id between @ini and (@ini + @pst + @ext - 1) group by s.voca_eng order by ID) as res where res.id between (@ini + @pst) and (@ini + @pst + @ext - 1)) order by rand() limit 5) ;
  •  학생부