问题如下:
SELECT Classroom_ID FROM classroom where Classroom_ID NOT IN (
select Classroom_ID From application  t1 Where "201601072" >= t1.Time_begin And "201603025" <= t1.Time_end
UNION
select Classroom_ID From application  t2 Where "201601072" <= t2.Time_begin And "201603025" >= t2.Time_end
UNION
select Classroom_ID From application  t3 Where "201601072" <= t3.Time_end And "201603025" >= t3.Time_end
UNION
select Classroom_ID From application  t4 Where "201601072" >= t4.Time_end And "201603025" <= t4.Time_begin );解释:虽然语法是对的但是运行一直错。解决办法
表的别名前加 as

解决方案 »

  1.   

    不用加as啊 
    mysql> SELECT Classroom_ID FROM classroom where Classroom_ID NOT IN (
        -> select Classroom_ID From application  t1 Where "201601072" >= t1.Time_begin And "201603025" <= t1.Time_end
        -> UNION
        -> select Classroom_ID From application  t2 Where "201601072" <= t2.Time_begin And "201603025" >= t2.Time_end
        -> UNION
        -> select Classroom_ID From application  t3 Where "201601072" <= t3.Time_end And "201603025" >= t3.Time_end
        -> UNION
        -> select Classroom_ID From application  t4 Where "201601072" >= t4.Time_end And "201603025" <= t4.Time_begin );
    Empty set (0.03 sec)mysql> 
      

  2.   

    表示mysql 5.6.34 无此问题。按理来说加不加as 都一样的呢