Olaf, > fb 2.1 cs is running > > Now I have four tables: > > Persons: > ID > Name > EMAIL > > ORDER: > ProjectID > PERSON_WHO_GET (references ID from Persons) > STATUS > > Projects: > ProjectID > Manager (references ID from Persons) > > ProjectSEND: > ProjectID > PERSON_WHO_GET_INFO (references ID from Persons) > > Each Person (ID) is unique, each ProjectID too. Every order has one > person_who_get, one Project has 1:n orders. In ProjectSend can I configure > many persons who get an email for one Project. > > Starting with the order table and its status (open), I can reference to the > project, than to the projectSend-Table. I would get all Persons (ID) grouped, > which are deposited with the order, the project (in dependence on > procect) and who is configurated to became an email (ProjectSend) > > > For example: > > Order 123 > Person who get Order: 2 > For Projekct ABC > ProjectManager for ABC: 23 > > ProjectSend f > Project: ABC, Person_who_get_info: 32 > Project: ABC, Person_who_get_info: 33 > > > Now I would get some results: > > Person 2 > Person 23 > Person 32 > Person 33 > > It is possible without a stored procedure?
Yes, UNION is your friend! SELECT Order.PERSON_WHO_GET as Person FROM Order WHERE Order.ID = 123 UNION SELECT Project.Manager as Person FROM Project JOIN Order ON Order.ProjectID = Project.ProjectID WHERE Order.ID = 123 UNION SELECT ProjectSend.Person_who_get_info as Person FROM ProjectSend JOIN Order ON Order.ProjectID = ProjectSend.ProjectID WHERE Order.ID = 123 Sean
