SQL tables are unordered sets. Thus, there are no such things as the first five rows or the last row - unless the column explicitly defines the order.
Often a table has a kind of column with an auto-increment identifier that can be used for this purpose. If so, you can do:
(select t.*
from t
order by id asc
limit 5
) union all
(select t.*
from t
order by id desc
limit 1
);
Notes:
- Sometimes the insert date / time column is the corresponding column to use.
union all
, union
- .- , 6, .