join - How to do a sql conditional joining on multiples tables? -


I already have a SQL request that is collected by joining up to 8 tables, to add an experimental information to me 3 Moray's table will add my information.

For this purpose, we can ignore 6 tables (bundled in other_tables ):

In the red box, I want to add it to its share. I just want to add request which respects certain conditions, if no one is found, I still want my person, but there is no data in the Request column.

So far I tried to do this, but more than one dropped looks ugly and very inclusive. Choose

  [internal] from request.Id [action] [on other tables] ... join the internal person in action. PixID = Person.Id r.PersonId = Request to join person.Id as R is abandoned. S. SubjectId = r.SubjectId should be included as leaving on tr.IDSujet = s.SubjectId TypeRequest tr Where ([conditions already existing]) and typeRequest = 'MOVE' (?)  
< P> And once again what should I do: I can get some ), even person if that person If there is a request of a specific TypeRequest , add the request ID to the data row.

Does the query work? "Looks ugly and very inclusive" is a bit unclear Do you want results? You can also take a part of where the section is attached to join with:

  Select [...], request from [action] Connect with Individual on Individual Action [Other tables ...] from IND PersonId = person.Id r.PersonId = A request to join the person as R. Sd. SubjectId = r.SubjectI, leave the topic left on tr.IDSujet = s.SubjectId ** Leave the request type and typeRequest = 'MOVE' ** Where ([conditions already present]]  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -