MYSQL查询语法修正

时间:2011-08-11 12:12:01

标签: mysql

需要一些关于MYSQL查询语法的帮助,我能够获得最后60条记录,但想要排除本周的记录。我正在尝试跟随,但无法找出正确的语法。

select TIMESTAMP,ID,MAX,MIN from 
 (select TIMESTAMP,ID,MAX,MIN from db 
  where ID = 'A0101'  
  WHERE YEARweek(TIMESTAMP) =! YEARweek(current_DATE) 
  group by TIMESTAMP desc limit 60) t 
order by TIMESTAMP asc

2 个答案:

答案 0 :(得分:2)

select TIMESTAMP,ID,MAX,MIN from db 
  where ID = 'A0101'  
  AND YEARweek(TIMESTAMP) != YEARweek(current_DATE) 
  group by TIMESTAMP desc limit 60
order by TIMESTAMP asc

更像这样......

答案 1 :(得分:0)

可能仅=!否定YEARweek()并与其他YEARweek()进行比较。

您应该尝试!=

目前,我无法说清楚,因为您没有显示错误或查询发生或未发生的情况。