使用codeigniter和mysql连接select和count

时间:2013-10-28 02:55:30

标签: mysql codeigniter

我有三张表如下:

tblHelpdeskType(需要与tblHelpdesk一起加入)

HelpdeskTypeID | HelpdeskType         |  Current
        1      | Not Specified        |  -1
        2      | Feature Request      |  -1
        3      | Account Request      |  -1
        4      | Permission Requested |  -1
        5      | Bug                  |  -1

tblHelpdesk(主要表)

HelpdeskID||HelpdeskTypeID||HelpdeskPriorityID||RequestBy||DateTimeStamp||HelpdeskStatusID
    1         || 1            || 2                ||sothorn  || 12/12/12    || 1
    2         || 3            || 1                ||Chantra  || 12/12/12    || 1
    3         || 1            || 1                ||Lyhong   || 12/12/12    || 2
    4         || 3            || 1                ||bongthom || 12/12/12    || 1  

tblHelpdeskStatus(需要与tblHelpdesk一起加入)

HelpdeskStatusID   | HelpdeskStatus
    1                  | Pending
    2                  | View
    3                  | In treatment
    4                  | Closed

我需要的结果是:

Type                  | Pending | View | In treatment | Closed  |
----------------------------------------------------------------|
Not Specified         |    1    |   1  |              |         |
----------------------------------------------------------------|
Feature Request       |    2    |      |              |         |
----------------------------------------------------------------|
Account Request       |         |      |              |         |
----------------------------------------------------------------|
Permission Requested  |         |      |              |         |
----------------------------------------------------------------|
Bug                   |         |      |              |         |
----------------------------------------------------------------|

0 个答案:

没有答案