Home > database >  How to record the status of the query
How to record the status of the query

Time:10-25

Scene description: a series of courses, a course that enter click [begin learning] produce learning record, status of the study, click [learning] end state for the end of the study, a direct query marked all courses and learning state (not start/end of study/learning), no problem, now according to learning state filtering, don't know how to write the query,
Mysql database
Have two tables: record the course curriculum, study_course_tag history learning status, including course_id field course table id, record the status field in the learning state status=1, the status=2 end of learning, no record did not start to learn the course,
According to status (not start/end of study/learning) query curriculum

Query statements of all state has:
Select c. * (select the status from study_course_tag as r where the and r.c ourse_id=c.i d order by id desc limit 1) as study_status
The from course as c order by id desc
(study_status=null correspondence did not start; Study_status=1 corresponds to the study; Corresponding learning study_status=2 end)

Who is a great god help see according to the status screen how to write the query???????
  • Related