SELECT MIN(id), MAX(id) FROM tabla
EDIT: Jika Anda perlu mengambil kembali nilai baris, Anda dapat melakukan ini:
SELECT *
FROM TABLA AS a, (SELECT MIN(id) AS mini,
MAX(id) AS maxi
FROM TABLA) AS m
WHERE m.maxi = a.id
OR m.mini = a.id;