当前位置:网站首页>The sixth MySQL job - query data - multiple conditions

The sixth MySQL job - query data - multiple conditions

2022-06-26 10:28:00 m0_ sixty-one million nine hundred and sixty-one thousand eight

  1. Query the teacher table T2 To T9 The salary is greater than 2000 And there are all field data of teachers with post allowance SELECT * FROM  lingjinzhengteacher where no between “T2” and “T9” and
  2. sal>2000 and comm is not null;

The teacher's name in the query teacher table does not start with a letter “A” All field data of teachers at the beginning , Sort by salary , Go to the first three

select * from lingjinzhengteacher where name not like "a%"  order by sal limit 3

 

Query the salary in the teacher table is equal to 2000 perhaps The post allowance is greater than or equal to 1000 All field data of teachers

select * from lingjinzhengteacher where sal = 2000 or comm >=1000;

 

4. The teacher's name in the query teacher table is written in letters “d” start also contain ”a” Letter teacher number 、 Teacher name field data

select no, name from lingjinzhengteacher where name like "b%a%" ;

 5. The teacher's name in the query teacher table does not use the character “e” At the beginning also Teacher number without post allowance 、 Teacher's name 、 Wages 、 Position allowance field data , Sort by salary

select no, name,sal, comm  from lingjinzhengteacher where name not like "e%" and comm is null;

  6. Query the curriculum with letters ”L” Of also The number of class hours is greater than or equal to 50 Course name 、 Class digital segment data

select name, class_hours from lingjinzheng_course where name like "%l%" and class_hours >=50;

 7. Query the course number in the course schedule C5 To C7 Between perhaps There is no field data for the number of class hours

select * from lingjinzheng_course where no between "C5" and "C7" or class_hours is null;

 8. The number of class hours in the query curriculum is not equal to 45 also The course name begins with “sh” Course name at the end 、 Class digital segment data

select name, class_hours from lingjinzheng_course where class_hours  !=  45 and name like "%sh" ;

 9. The course number in the query course table is not in C3、C5、C6 in perhaps The number of class hours is equal to 45 All field data , Sort by class hours

select * from  lingjinzheng_course  where  no not in ("C3", "C5", "C6") or class_hours = 45 order by class_hours;

  Query the serial number in the teaching table 2 To 9 Between perhaps The number of weeks is 15 The serial number of 、 Classroom number 、 Week field data

select id, class_num, week from lingjinzheng_schoolteaching
 where id between 2 and 9
 or week = 15;

  Query the teacher number in the teaching table T2 To T9 Between also The classroom is J Dong's teacher number 、 Classroom number field data , Sort by weeks

select teacher_no, class_num from lingjinzheng_schoolteaching
    -> where teacher_no between "T2" and "T9"
    -> and class_num like "J%"
    -> order by week;

 

  The number of weeks in the query teaching table is not empty also The number of weeks is greater than or equal to 50 My course number 、 Classroom number 、 Week field data

 select course_no, class_num, week from lingjinzheng_schoolteaching
    -> where week is not null and week >= 50;

 

  1. 5 The classroom in the inquiry teaching table is on the first floor perhaps All field data of the classroom on the third floor , Sort by weeks

 

select * from lingjinzheng_schoolteaching where class_num like "_1%" or class_num like "_3%" order by week;

 

原网站

版权声明
本文为[m0_ sixty-one million nine hundred and sixty-one thousand eight]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260930072497.html