1

I have following two tables:

user:

+---------+--------------+
| 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 |
+-----+--------+------+----------+

I want to match values of SKILLS columns of table pskills. Such as if query is done with first row of pskills and join with user table then it will return User ID 1 because SKILLS 2,4 match with user id 1 only. How can i do this easily?

4

1 回答 1

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 |
+-----+--------+------+----------+
于 2013-10-01T09:25:39.823 回答