Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Querying tables with one to many relationship

Author  Topic 

gousia
Starting Member

3 Posts

Posted - 2008-04-11 : 12:13:55
Hi There,

Could You please look into this and help me to obtain the more appropriate solution

Lets assume that we have two tables with one to many relationship.one table contains employee's and the other contains communication made by employee to the clients. An employee might have communicated to the client one or more times or may not have communicated at all.
(Employee -> Communication = one ->many)

I m trying to write a query which display all the records of employee's and their respective communication text with out repetition of the employee id or employee name. I need the records with null communication as well.

Ex :

Table 1 -

Empid(Pk) Empname
1 Sam
2 John
3 Ram

Table 2 -

Comid(Pk) Empid(Fk) Comtext
1 1 Hello
2 1 Hi
3 2 How are you
4 1 Thanks
5 2 Fine

Result required -

Empid EmpName Commtext
1 Sam Hello,Hi,Thanks
2 John How are you, Fine
3 Ram

Any help will be much appreciated.

Many Thanks,
G

Ps : The above ex is just an example. don;t look at it logically :)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-11 : 12:42:26
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293
Go to Top of Page

gousia
Starting Member

3 Posts

Posted - 2008-04-16 : 17:10:55
quote:
Originally posted by visakh16

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293



Hi Visakh,

Many Thanks for your help. You are a Star!

Cheers,
G
Go to Top of Page
   

- Advertisement -