you have this 2 tables:
table1
-------------
id
fromId
fromOtherTableId
person
and
Table2
-------------
OtherTableId
Person
first question
this query work fine
select t.id
from table1 as t inner join Table2 as a on t.fromOtherTableId=a.OtherTableId
where a.Person = 54
union
select t1.id
from table1 as t1 inner join Table1 as t2 on t1.fromId=t2.fromId
where t2.Person = 54
how to remove the union so the query would still be working?
second question
how would you manage the fact that you cannot create an entry in table1 where table2.fromothertableid(person) would be put into table1.person(circular thing)
same with the fact that you cannot create an entry in table1 where table1.fromid(person) would be put into table1.person(circular thing)
this would be good:
table1
---------------
1, null, 1 , 100
2, 1, null , 200
table2
--------------
1, 200
this wouldn't be good(between **)
table1
---------------
1, null, 1 , 100
2, 1, null , 200
**3, 1, null , 100**
**4, null, 1, 200**
table2
--------------
1, 200