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)
 Please help me - this SQL-query makes me mad

Author  Topic 

Medea
Starting Member

1 Post

Posted - 2006-07-26 : 07:07:58
Hello,

this is my first post on this gerat forum.

I would like to show some relationships between my customers.
I have customers, whose are partners of me. With my SQL query I would like to show this relationship.

The data model looks like this.

Customer
-id
-name
-person_id

Person_relationship
-id
-person_id
_person_rel_id
_person_rel_function_id

person
-id
-name
-adress_id

function
-id
-title (manager,partner e.g.)

I would like to show some kind of relationship
customer.person_id->person_relationship_person_id to get all my partners with the person_function_id and then their managers, if they have some.

I did it with a UNION SQL query but the issue was terrible.

Could anyone help me with this SQL query.
The result should contain my partner and his/her manager.

Thanks for your help.

Best regards

Medea

Q
Yak Posting Veteran

76 Posts

Posted - 2006-07-26 : 07:31:15
from customer inner join Person_relationship on
customer.person_id = person_relationship.person_id

this will lin the 2 tables. Hopefully you can fill in the rest...
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-07-26 : 09:06:31
you need to learns on JOINS and TYPES OF JOINs

This will help you do any kind of query from the differnt tables.

Chirag
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-27 : 11:28:35
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -