表名:资源编写查询以特定的方式来获取数据
res_id | first_name
1 clyde
2 John
3 Rachel
4 Jason
5 Rasmon
6 Pierson
7 Jamson
8 Radamel
表名:probation_hr
probation_id | res_id | month_id | hr_id
1 1 M1 4
2 1 M2 4
3 2 M1 4
4 2 M2 4
表名:probation_feedback
prob_id | reviewer_id | res_id
1 6 null
1 7 null
1 8 null
1 null 1
RES_ID在不为空缓刑反馈表意味着缓刑犯已经填补了他的反馈意见
给定一组RESOURCE_ID的,我希望获取他的细节如下
resources.first_name,
probation_hr.month_id,
probation_hr.probation_id,
probation_hr.hr_id (also get this id's first name from resources table),
and lastly get all records from probation_feedback table where
probation_hr.probation_id = probation_feedback.probation_id (here there are multiple records, so do i use another array here?)
单个示例情况: RESOURCE_ID = 1 输出: 克莱德(resources.first_name),4(probation_hr.hr_id), M1(probation_hr.month_id),1(probation_hr.probation_id),阵列(从probation_feedback表,其中probation_id = 1的记录):
1 6 null,
1 7 null
1 8 null
1 null 1
我如何做到这一点的一个查询?
是否有可能?
如果不可能比我怎么做呢? 我使用2d数组吗?
即时通讯使用PHP和MySQL
thanx提前
什么?你能否将你的问题归结为可以理解的主要问题?并格式化代码/表格defs,以便从评论中分离出来? (点击右上角的'?'查看如何) – Jeff