我问过这个问题,但不得不normalze甚至有机会计算出这个mysql加入的条件
我被困在查询。一位主管(7的ID可以说)将职位发布到职位表上。当他发布帖子时,他为该帖子设置了0-4的组级别......所有这些都保存在作业表中。现在我想要在页面上显示这些内容
如果作业relevant_group设置为0,则允许任何人查看它。如果工作相关组未设置为0,那么我们需要抓住观众会话employee_id,并使用它来查看他们是否在该主管的其中一个组中
因此,如果员工登录并且他的ID是在该主管的团队记录之一中...然后我想显示该职位列表。员工可以与其他监管其他群体,但我只是想显示工作,如果他们是由job_lister_id张贴在工作表中的job_lister_id和supervisor_id在组表的组中的将是相关配套领域
jobs table
job_listing (text I want displayed in this field)
job_lister_id (int same as supervisor_id in table below)
relevant_group (enum 0,1,2,3,4)
groups table
supervisor_id (int same as job_lister_id in table above)
group_number (data will either be 1,2,3 or 4)
employee_id (int id number of employee)
所以现在我需要呼应的所有记录
SELECT * FROM jobs
- if relevant_group == 0, go ahead and echo that one
- if relevant_group != 0
- I need to see if the users session id is in a record for the supervisor for that group in groups table
- if it is echo it, else skip it
布赖斯,你的SQL缺少活动用户ID – Richard 2011-12-17 18:50:33
检查。我已将employee_id添加为绑定变量。 – Aaron 2011-12-17 18:58:37
ahhhh!揍你,那就是我所需要的。我不得不从enum更改我的relevant_groups,因为它不能正常工作 – 2011-12-17 19:30:42