Well i have two tables first for employees and the second for emails, i want to see the employees with all his emails
table employees:
id | name | idE
1 | name1 | 1
2 | name2 | 2
3 | name3 | 3
table email:
id | idE | email
1 | 1 | e1@email.com
2 | 1 | e2@email.com
3 | 2 | e@email2.com
4 | 3 | e@email3.com
and i have this query:
select e.id, e.name, m.email from employees as e inner join email as m on p.idE = m.idE
and this is the result:
id | name | email
1 | name1 | e1@email.com
1 | name1 | e2@email.com
2 | name2 | e@email2.com
3 | name3 | e@email3.com
i dont need employee 1 twice i just need both emails in the same row
Hi guys i modified my query to: select em.name, STUFF( (select ',' + e.Email from tbl_Employees as m inner join tbl_Email as e on m.idE = e.idE for xml path('')) ,1,1,'') as emails from tbl_employees as em
but now my problem is that i get this in each column of email:
e1@email.com,e2@email.com,e@email2.com,e@email3.com,
how can i do it to get only the emails of each employee?
instead of having every single email in each column
for example:
name | email
name1 | e1@email.com,e2@email.com,
name2 | e@email2.com,
name3 | e@email3.com,
pd: sorry if i have some mistakes im still learning english