We can do this by using UNION as follows:
Table Student is As follows:
| id | Name |
| 1 | Shyam |
| 2 | Manu |
| 3 | Murari |
| 4 | Ranu |
| 5 | Pankaj |
Select A.id,A.name from (select id,name from student order by id asc limit 1) A UNION select B.id,B.name from (select id,name from student order by id desc limit 1)B
After Execution of this Query we will get
| Id | name |
| 1 | Shyam |
| 5 | Pankaj |
No comments:
Post a Comment