尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

4.27笔记

4.27笔记 组合查询所有年龄小于海伦凯勒的人员列表select*fromstudentwherebirthday(selectbirthdayfromstudentwherestudentName海伦凯勒)andnational汉族;#都比海伦凯勒大多少年selectTIMESTAMPDIFF(YEAR,NOW(),(selectbirthdayfromstudentwherestudentName海伦凯勒));#计算年龄月份差selectTIMESTAMPDIFF(MONTH,birthday,(selectbirthdayfromstudentwherestudentName海伦凯勒))fromstudentwherebirthday(selectbirthdayfromstudentwherestudentName海伦凯勒);#主表 多表查询得到结果select*fromstudentass#首先连接主表相关的表 表scoreinnerjoinscoreasscons.studentNosc.studentNoinnerjoincourseasconc.courseNosc.courseNowheresc.result78andcourseNamepython程序设计;#--由于ci 所以支持不区分大小写查询#使用子查询的方式来获取数据select*fromstudent#在学生表里找到程序设计 成绩是78的学生是谁wherestudentNo#--子查询(selectstudentNofromscorewherecourseNo(selectcourseNofromcoursewherecourseNamepython程序设计)andresult78);
返回列表