users

id     username           password
----------------------------------
1      [email protected]    admin
2      [email protected]   password
3      [email protected]      admin123


employer-profile

id     u_id   company-name       logo
-----------------------------------------
1      2      Blue Rays Graphics logo.jpg
2      1      Hire Me to do best logo.jpg
3      3      example.com        logo.jpg


employer-post-job

id     e_id   job-title     job-category    expire date
-------------------------------------------------------
1      2      web-developer IT              2013-9-5
2      1      receptionist  media           2013-9-5
3      2      web-designer  IT              2013-9-5


在此表中,我想像这样在索引页中列出数据

------------
|          |  Blue Rays Graphics
|   logo   |
|          |
------------

------------
|          |  Hire Me to do best
|   logo   |
|          |
------------


在此表中,我想列出未到期的雇主,如果到期,则由雇主发布的所有工作都不仅仅是隐藏雇主列表,我希望它通过mysql查询在CI Framework中列出。

我试过了

SELECT *
FROM employer_profile
WHERE u_id IN
        ( SELECT DISTINCT u_id
         FROM employer_profile
         INNER JOIN
             ( SELECT e_id,
                      COUNT(*)
              FROM employer_post_job
              WHERE dead_line >= CURDATE()
              GROUP BY e_id )
         INNER JOIN users ON employer_profile.u_id = users.id);

最佳答案

尝试此查询,如果您仍然遇到问题,让我解决,因为我无法执行它。

Select * from users u
          inner join employer-profile e ON u.id = e.u_id
          inner join employer-post-job epj ON e.u_id =epj.e_id
          where epj.expire date > '".date('Y-m-d')."'

关于php - 如何使用MySQL查询CI列出数据并仅列出未过期的已发布雇主和职位,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18638159/

10-13 22:20