我有一张表格如下
如何实现查询,使其变为如下
-------------------------------------------------------------------------------
| name_applicant| siteplan| date | detail |
-------------------------------------------------------------------------------
| aaa | tapak1 | 12-12-2013 | name_of_detail_1 : value_of_detail_1 |
| name_of_detail_2 : value_of_detail_2 |
| name_of_detail_3 : value_of_detail_3 |
| name_of_detail_4 : value_of_detail_4 |
-------------------------------------------------------------------------------
| bbb | tapak2 | 13-12-2013 | name_of_detail_1 : value_of_detail_1 |
| name_of_detail_2 : value_of_detail_2 |
| name_of_detail_3 : value_of_detail_3 |
| name_of_detail_4 : value_of_detail_4 |
-------------------------------------------------------------------------------
非常感谢
答案 0 :(得分:0)
这会给你一个很好的起点我想:
SELECT a.name_applicant,
s.plan as siteplan,
b.date,
CONCAT(d.name,' : ',d.value) as detail
FROM applicant a
INNER JOIN book b ON b.idapplicant = a.idapplicant
INNER JOIN siteplan s ON s.idsiteplan = b.idsiteplan
INNER JOIN detail d ON b.idbook = d.idbook