我在查詢時遇到問題。我有4個表選擇列,如果存在於表2中或存在於表3或表4中
first table: person
ID_No
-----
1
2
3
second table: update_general_details
Update_ID ID_No Email Mob_No
--------- ----- -------------- --------
1 1 [email protected] 078231231
third table: update_training
Training_ID ID_No Training_Name Training-Date
----------- ---- ------------- -------------
1 2 Mysql training 2014-09-09
third table: update_award
Award_ID ID_No Award_Name Award_Year
-------- ----- ----------- ----------
1 1 Best in Math 2010
我所要做的就是選擇不同的ID號,其中的ID號可以包含在第二臺或第三或第四。 期望的結果:
ID_No
1
2
這裏是我的代碼:
Select DISTINCT person.ID_No,
from update_award, update_general, update_training, person
where EXISTS (SELECT update_award.ID_No
FROM update_award, person
WHERE person.ID_No = update_award.ID_No) or
EXISTS (SELECT update_training.ID_No
FROM update_training, person
WHERE person.ID_No = update_training.ID_No) or
EXISTS (SELECT update_general_details.ID_No
FROM update_general, person
WHERE person.ID_No = update_general.ID_No)
該查詢返回任何內容。預先感謝您
你似乎有麻煩計數到4 – Strawberry