我有2張桌子。從兩個表中獲取數據?
之一成立問題:
id | question
1 How old are you?
2 Are you male of female?
其他持有考試:
id | title | question_ids
1 Summer Exam [1,2]
我的問題是,我想選擇考試表格中的考試,並獲得所有的相關問題該特定考試(question_ids字段),但是從問題表中獲取問題,而不僅僅是存儲在question_ids中的標識。
我該怎麼做?
如果您在問題表中存儲問題所屬考試的ID,將更容易找出答案:您真正顯示的P – BlackBear 2013-03-07 20:44:42
使用弱實體來存儲'question_IDs'。這是非常糟糕的數據庫設計方式。 – 2013-03-07 20:45:45
不要在數據庫中存儲'[1,2]''。而是建立一個鏈接表'examQuestions',它具有'examID'和每個'questionIDs'。 – 2013-03-07 21:28:41