sql - mysql无法获得group_concat,group by,transpose的所需结果

时间:2016-05-30 09:08:36

标签: php mysql sql

给你一个问题的例子我面临创建mysql查询。使用group_concat或group by不会给我我想要的结果。

任何人都可以告诉我如何实现以下结果?如果可以使用过程或视图来解决它,那就没问题。

用户

===============
| Id | UserId |
=====+========|
| 1  | 297    |
---------------

workex

=======================================================
| wid | UserId | title                      | company |
=====+========+===============+=======================|
| 1  | 297    | software engineer           | x       |
|----+--------+---------------+-----------------------|
| 2  | 297    | sr software engineer        | y       |
-------------------------------------------------------

教育

=========================================================
| eid | UserId | title                      | institute |
=====+========+===============+=========================|
| 1  | 297    | computer science            | p         |
|----+--------+---------------+-------------------------|
| 2  | 297    | MS software engineering     | q         |
---------------------------------------------------------

结果

=====================================================================================================================================================================================
| userid  | workex_title                        | company | workex_title                | company | education                   | institute |education                   | institute |
=====+========+===============+======================================================================================================================================================|
| 297     | software engineer                   | x       | sr software engineer        | y       | computer science            | p         |sr software engineer        | q         |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

0 个答案:

没有答案