Content

  Title: query03

set @snm = 'm1'; set @pst = 50; set @ext = 10; set @ini = (select min(id) from sources where source_name collate utf8mb4_unicode_ci = @snm); select tmp.ID as ID, tmp.English as English, v.pro as Pronunciation, v.kor as Korean from (((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 < @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)) as tmp join vocas v on v.eng = tmp.English order by tmp.English;
  •  학생부