You need to run two queries for this
Assumption:
ID is the primary key and it keeps increasing by some increment
For getting the first record
select * from sometable LIMIT 1;
For getting the last record
select *,max(ID) from TBL_CONTACT_MASTER GROUP BY ID DESC LIMIT 1;
This is a round about of way of doing things there may be a better way to do it