0
あなたは、この2つのテーブルがあります。これらの2つのクエリとこの制約を作成する方法の間の和集合を削除することは可能ですか?
table1
-------------
id
fromId
fromOtherTableId
person
と
Table2
-------------
OtherTableId
Person
最初の質問を
トンので、労働組合を削除する方法
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
微この問合せ作業彼は依然としてクエリが機能していますか?
あなたはtable2.fromothertableid(人が)table1.person(円形のもの)の中に置かれるTABLE1にエントリを作成することができないという事実を管理する方法を2つ目の質問
同じあなたはtable1.fromid(人が)table1.personに置かれるTABLE1にエントリを作成することができないという事実(円形のもの)
でこれは良いでしょう:
table1
---------------
1, null, 1 , 100
2, 1, null , 200
table2
--------------
1, 200
これは質問1
table1
---------------
1, null, 1 , 100
2, 1, null , 200
**3, 1, null , 100**
**4, null, 1, 200**
table2
--------------
1, 200
ユーザー定義関数と制約を使用して問題2を修正しました。私は現在、あなたのクエリをテストしています。それがうまくいけば、私は明日も緑色のチェックで戻ってきます。 – Fredou