There are few rows:
Id marks
1 15
1 16
1 17
2 6
2 15
3 9
3 10
I want to merge all the id into a single row, with output like below:
Id marks1 marks2 marks3
1 15 16 17
2 6 15
3 9 10
Concatenating fields into a single field is made really easy in mysql. there is function for it. CONCAT(). Better yet if you and want to delimit them by the same string you can use CONCAT_WS(). which is concatenate with separator, the first parameter being the separator and any other argument after being a field you wish to join.
http://www.w3resource.com/mysql/string-functions/mysql-concat_ws-function.php
SELECT id, CONCAT_WS(' ', marks1, marks2, marks3) as 'mark1 | mark2 | mark3' from my_table group by id;
UPDATE
I think I Misunderstood your schema structure. I think what you actually are looking for is GROUP_CONCAT().
SELECT id, GROUP_CONCAT(marks) as 'All Marks' from my_table group by id;