0
I am sure it is something simple, but I am not succeeding: I will give the example.
tb_empresa e tb_contatosdaempresa
Each company has up to 8 contacts (Fields: id_company / name / phone / email)
I need to make an Inner Join in a way that for each company returned (tb_company) appear all the contacts and their respective data, but vertically, in columns, to then export to Excel !!! Type:
Line01 >> Company Name | Name Contact 01 | Phone Contact 01 | Email Contact 01 | Name Contact 02 | Phone Contact 02 | Email Contact 02...
Line02 >> Company Name | Name Contact 01 | Phone Contact 01 | Email Contact 01 | Name Contact 02 | Phone Contact 02 | Email Contact 02... Thus
Line03 >> Company Name | Name Contact 01 | Phone Contact 01 | Email Contact 01 | Name Contact 02 | Phone Contact 02 | Email Contact 02... Thus
So consectively until the eighth contact, even if you do not have 8 contacts registered for this company (In the case is blank). Because the way you’ve been doing, a line is created for each contact the company has, repeating the name of the company several times.
Can you give me a hand ???
Depending on the DBMS used there are tools for this. In Postgresql the function Crosstab of tablefunc can help you. Other DBMS implement Feature pivot.
– anonimo
I believe that is the way. I will study this Feature because it is Mysql. Vlws
– Naimar Nunes