A表:
id 学生主键id
del_flag 删除标识
name
sex
age
B表:
aid 考勤表主键id
attendance_location 考勤地点str
attendance_time 考勤时间str
attendance_device 考勤设备str
sid 考勤记录对应的学生id
create_date 考勤时间
sql实现:
SELECT
A.id,
A.del_flag as delFlag,
A.name,
A.sex,
A.age,
B.attendance_location as attendanceLocation,
B.attendance_time as attendanceTime,
B.attendance_device as attendanceDevice
FROM
students A
leftjoin(select
a.attendance_location,
a.attendance_time,
a.attendance_device,
a.sid,
a.create_date
from attendances as a
rightjoin(selectmax(create_date)as crdate,
sid
from attendances
groupby sid)as b
on a.sid=b.sid
where a.create_date=b.crdate
)as B
on A.id=B.sid
where
A.del_flag =0<if 条件 可不要>and xxx
</if>------ 此为查询 所有学生的 个人信息数据