0

我有这个 sql:

SELECT YEAR(`end`) as week, WEEK(`end`) as year
FROM table
WHERE week=24 AND year=2016 

但我得到了错误Unknown column week in where clause。我做错了什么?请帮帮我。提前谢谢

4

1 回答 1

2

您不能在where子句中使用别名,试试这个;)

SELECT WEEK(`end`) as week, YEAR(`end`) as year
FROM table
WHERE WEEK(`end`)=24 AND YEAR(`end`)=2016 
于 2016-06-15T08:26:18.533 回答