Kavi suja

Kavi suja

  • NA
  • 298
  • 167.6k

MySql - Case -Retrieve data

Jul 17 2013 5:56 AM
Hi,
   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 Email
401 8708708700
401 [email protected]
But I want to generate the output in single line as follows
hisPkey Mobile Email
401 8708708700 [email protected]
Can any one help me to do this?



Answers (4)