我有以下两个表:
用户:
+---------+--------------+
| user_id | skills |
+---------+--------------+
| 1 | 1,2,3,5,4,14 |
| 2 | 1,2,3 |
| 3 | 3,4,5 |
| 4 | 1,2 |
+---------+--------------+
pskills:
+-----+--------+------+----------+
| PID | SKILLS | SPLI | status |
+-----+--------+------+----------+
| 1 | 2,4 | 1 | |
| 1 | 1 | 1 | required |
+-----+--------+------+----------+
我想匹配表 pskills 的 SKILLS 列的值。例如,如果使用第一行 pskills 进行查询并使用用户表加入,则它将返回用户ID 1,因为SKILLS 2,4仅与用户ID 1匹配。我怎么能这么容易做到?
答案 0 :(得分:4)
你应该像这样规范你的表
**user**
+---------+--------------+
| user_id | skills |
+---------+--------------+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | ... |
| 2 | 1 |
| 2 | 2 |
| | ... |
+---------+--------------+
**pskills**
+-----+--------+------+----------+
| PID | SKILLS | SPLI | status |
+-----+--------+------+----------+
| 1 | 2 | 1 | |
| 1 | 4 | 1 | |
| 1 | 1 | 1 | required |
+-----+--------+------+----------+