Q:

how to create query for below table

This is the table of database
**
id  products  free_pro_id
 1  laptop              2
 2  pen-drive           -
 3  hard-disk         2,4
 4  mouse               3

i am just wondering how to create query  for below output
product   free_id_pro**
laptop    pen-drive
hard-disk pen-drive,mouse
mouse     hard-disk

A:

I understand your problem. But your table implementation is not correct. 
First, you have to learn about Database Normalization.
Please refer to this link
https://www.studytonight.com/dbms/database-normalization.php
You can have a table for products and another table for promotions.
Table Products
In this table you can have the prodId and the prodName
prodId-------prodName
1--------------laptop
2--------------pen_drive
3--------------hard_disk
4--------------mouse
Table Promotion
In this table, you can store what are the free products you are giving when user buys a product.
promoId--prodId----freeProdId
1-------------1------------2
2-------------3------------2
3-------------3------------4
4-------------4------------3
If you want to get the free products given for laptop you can do the following query
SELECT freeProdId from Promotion where prodId = 1;

I have given a very simple query to give you a basic understanding. You can modify the query, play around with it and do many things. (Ex. Get the prodName instead of the id)

