我想要做的是通過相似/相似的順序問題,然後從Result
表中得到 結果來自Point
表中的點數。MySQL - 我如何讓我的查詢做到這一點?
例:查詢= '德國位置'
我有以下表:
表問題
+---------+-----------+---------------+---------------------------------+
| ques_id | question |
+---------+-----------+---------------+---------------------------------+
| 1 | Where is Germany located |
+---------+-----------+---------------+---------------------------------+
| 2 | where is Germany located on a map |
+---------+-----------+---------------+---------------------------------+
| 3 | where is Germany located in Europe |
+---------+-----------+---------------+---------------------------------+
表結果
+---------+-----------+---------------+---------------------------------+
| resu_id | result |
+---------+-----------+---------------+---------------------------------+
| 1 | Germany is located in Europe |
+---------+-----------+---------------+---------------------------------+
| 2 | Northern hemisphere in Europe |
+---------+-----------+---------------+---------------------------------+
| 3 | between France & Poland |
+---------+-----------+---------------+---------------------------------+
| 4 | Germany is located in central Europe |
+---------+-----------+---------------+---------------------------------+
| 5 | South of Denmark |
+---------+-----------+---------------+---------------------------------+
| 6 | 52 degrees North, 13 degrees East |
+---------+-----------+---------------+---------------------------------+
| 7 | located on the continent of Europe |
+---------+-----------+---------------+---------------------------------+
表點
+---------+-----------+-----------+-----------+
| pont_id | ques_id | resu_id | point |
+---------+-----------+-----------+-----------+
| 1 | 2 | 6 | 10 |
+---------+-----------+-----------+-----------+
| 2 | 1 | 1 | 8 |
+---------+-----------+-----------+-----------+
| 3 | 2 | 7 | 7 |
+---------+-----------+-----------+-----------+
| 4 | 3 | 5 | 9 |
+---------+-----------+-----------+-----------+
| 5 | 3 | 4 | 8 |
+---------+-----------+-----------+-----------+
| 6 | 1 | 7 | 10 |
+---------+-----------+-----------+-----------+
| 7 | 3 | 2 | 6 |
+---------+-----------+-----------+-----------+
| 8 | 2 | 3 | 4 |
+---------+-----------+-----------+-----------+
我試圖
SELECT resu_id FROM `Point` WHERE ques_id is (**?**) ORDER BY `point`
期待結果依相關
+---------+-----------+-----------+--------------------------------------------+
| ques_id | resu_id | point | result |
+---------+-----------+-----------+--------------------------------------------+
| 1 | 7 | 10 | located on the continent of Europe |
+---------+-----------+-----------+--------------------------------------------+
| 1 | 1 | 8 | Germany is located in Europe |
+---------+-----------+-----------+--------------------------------------------+
| 2 | 6 | 10 | 52 degrees North, 13 degrees East |
+---------+-----------+-----------+--------------------------------------------+
| 2 | 7 | 7 | located on the continent of Europe |
+---------+-----------+-----------+--------------------------------------------+
| 2 | 3 | 4 | between France & Poland |
+---------+-----------+-----------+--------------------------------------------+
| 3 | 5 | 9 | South of Denmark |
+---------+-----------+-----------+--------------------------------------------+
| 3 | 4 | 8 | Germany is located in central Europe |
+---------+-----------+-----------+--------------------------------------------+
| 3 | 2 | 6 | Northern hemisphere in Europe |
+---------+-----------+-----------+--------------------------------------------+
排序問題,那麼基於點值相應的結果。
感謝所有的幫助,不要對我:)
如果您嘗試過,結果出了什麼問題?您是否正在按特定順序查找正確答案的結果ID或問題ID的結果ID列表? –
@Ravinder首先,我的查詢不排序問題的相關性,那麼它應該從'點'表找到resu_id然後按點排序它們。 – bekman
查看我更新的查詢,並且如果需要更多內容,則返回beck ... –