I have two tables 'contactinfo' contains 3 fields-- key,ContactModeList_pkey,value,whosinfo_pkey.
'whosinfo' contains fields-- pkey,hisPkey.Here 'contactinfo' table contains 2 rows for the same 'pkey' values.(The 'contactinfo' table contains two data for single whosinfo_pkey)
select whos.hisPkey ,
IF(ContInfo.ContactModeList_Pkey = 1, value, '') 'Mobile',
IF(ContInfo.ContactModeList_Pkey = 2, value, '') 'Email'
from whosinfo whos,contactinfo ContInfo where whos.pkey=ContInfo.whosInfo_pkey
and whos.pkey = '397';
The data in table 'contactinfo' as 422,1,8708708700,397 in next row 423,2,8708708700,397.The data in table 'whosinfo' as 397,401.
The ouput will be as following:
| hisPkey | Mobile | |
| 401 | 8708708700 | |
| 401 | [email protected] |
| hisPkey | Mobile | |
| 401 | 8708708700 | [email protected] |


Iftikar HussainRank #423 · 5.9K reputationPosted Jul 22, 2013, 12:29 AM EDT
Try like this
Regards,
Iftikar
Renish Patel160 reputationPosted Jul 22, 2013, 12:00 AM EDT
You have to used GROUP_CONCAT() function in MY SQL to solve your problem..
Here i share link for you,which will explain you every things which you want..
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
If you get your answerd then make this post as answered..
Happy Coding..
Thanks
Renish Ankola
Kavi sujaRank #6,237 · 272 reputationPosted Jul 22, 2013, 12:58 AM EDT
Thank you for your reply.It's working for me.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 22, 2013, 1:02 AM EDT
Regards,
Iftikar