我有ID、SID、CHECKID、DATE表student此处ID:tableID(自动递增),SID:studentID,CHECKID:0/1(即IN/OUT),DATE。当学生进入教室时,他将通过卡保存每日出勤率。我有数据是IDSID检查日期--------------------0101004-10-201310:00:001101104-10-201311:30:002101004-10-201314:15:00我试过这样的查询:选择DISTINCTSID,MAX(DATE),CHECKIDfromstudentwhereSID='101'groupbySID然后我得到了两条
我有一个MySQL左连接问题。我要加入三个表。一个人表:CREATETABLEperson(idINTNOTNULLAUTO_INCREMENT,typeENUM('student','staff','guardian')NOTNULL,first_nameCHAR(30)NOTNULL,last_nameCHAR(30)NOTNULL,genderENUM('m','f')NOTNULL,dobVARCHAR(30)NOTNULL,PRIMARYKEY(id));一个学生表:CREATETABLEstudent(idINTNOTNULLAUTO_INCREMENT,person_id
insertintostudent(FirstName,AGE,CITYID)values('guna','26','1')select*fromstudentWHEREFirstName!='guna';此查询显示错误。我无法将FirstName列设为唯一。请给出除此之外的想法。谢谢 最佳答案 INSERTINTOstudent(....)WHEREFirstNameNOTIN(SELECTFirstNameFROMstudent)修改和测试后:INSERTINTOstudent(FirstName,age,cityid)SELE
我的数据库中有2个日期表,student_info和student_payment...在student_info我有:id,student_id,student_mail,student_pass,student_name,...并且在student_payment中有:id,student_id,student_payment_id,student_payment_date,...所以我的问题在这里,我想选择student_name其中student_id形成student_info但我有问题,mysql给我一个错误:$db->connect();$sql="SELECT*FROM
我的数据库中有以下表格:CREATETABLEusers(idint(11)NOTNULLAUTO_INCREMENTPRIMARYKEY,usernamevarchar(100)NOTNULL,rolvarchar(100)DEFAULTNULL,)ENGINE=InnoDBDEFAULTCHARSET=latin1;CREATETABLEsubjects(subject_idint(11)NOTNULLAUTO_INCREMENT,subjecttext,PRIMARYKEY(subject_id))ENGINE=InnoDBDEFAULTCHARSET=utf8mb4AUTO_I
我有3张tabletable_student身份证、名字、姓氏表格类(class)ID,类(class)名称table_student_courseID,student_ID,course_ID,date_taken我想做的就是按ID=1的学生的course_name和date_taken列出所有类(class)有人要吗? 最佳答案 您需要在table_courses和table_student_course表上使用JOIN,然后在上应用OrderBycource_name按类(class)名称排序。要选择特定学生,请应用Where
我有这个插入行的查询,使用像这样的子查询:INSERTINTOLecture_presence_Student(`presence_id`,`Lecture_id`,`Student_id`,`status`)VALUES((SELECT''aspresence_id,Lecture.Lecture_id,CourseEdition_students_Student.Student_id,'onverwerkt'FROMCourseEdition_students_StudentINNERJOINLectureONCourseEdition_students_Student.Cours
我有以下mysql查询:SELECTcount(student_name)AStotal_student,school_nameFROM`student`LEFTJOINschool_infoONschool_info.school_id=student.school_idWHEREstudent.status='0'它返回:total_studentschool_name0NULL我想要实现的是,如果total_student=0则不显示任何值或NULLtotal_studentschool_name你能告诉我怎么做吗?谢谢:) 最佳答案
我的下一个问题是:我有一个像这样的mysql查询:SELECTstudent_id,name,emailFROMstudentWHEREstudent_idIN('1','2','3')ORnameLIKE'%Nick%'ORemailLIKE'%gmail.com%'如何以mysql返回的列的形式获取a中匹配字段的个数像这样:IDNAMEEMAILMATCHED1.1Nicknick@gmail.com32.5Nicknick@yahoo.com13.2Daviddavid@gmail.com2谢谢!! 最佳答案 它很丑,但有点像
我的问题类似于MySQLSplitStringandSelectwithresults.目前我有2个表:学生uid|subject_id|name1|1^2^3^4|a2|2^3^|b3|1|c主题uid|subject_name1|math2|science3|languange4|sport我期望的结果是:uid|name|subject_passed1|a|math,science,languange,sport2|b|science,languange3|c|sport我试过这个查询:SELECTstudent.uid,student.name,group_concat(sub