php mysql查询帮助类别

时间:2015-09-09 12:04:54

标签: php mysql

表1

+----+-------------------------------+--------+--------+------+
| id |         thesis_title          | cat_id | status | year |
+----+-------------------------------+--------+--------+------+
| 10 | Project Award - 2014          | 1,2    | C      | 2014 |
| 11 | Project Award - 2015          | 1,2    | C      | 2015 |
| 12 | Research Award for PhD - 2015 | 3      | A      | 2015 |
+----+-------------------------------+--------+--------+------+

表2

+----+--------------------------+---------+
| id |         category         | Status  |
+----+--------------------------+---------+
|  1 | Undergraduate Course(UG) |       1 |
|  2 | Postgraduate Course(PG)  |       1 |
|  3 | PhD                      |       1 |
+----+--------------------------+---------+

我有两张桌子。

如果状态为C(已关闭)

,我想从表1中选择表2的类别

for ex:Table 1 contains cat_id 1,2(string separated by commas,表2将这些包含为id:1,2,3和类别。

所以我想从表2中为表1的cat_id选择相应的类别。

0 个答案:

没有答案