我有这个sql:
SELECT YEAR(`end`) as week, WEEK(`end`) as year
FROM table
WHERE week=24 AND year=2016
但我收到错误Unknown column week in where clause
。我做错了什么?请帮帮我。 Thx提前
答案 0 :(得分:2)
你不能在where
子句中使用别名,试试这个;)
SELECT WEEK(`end`) as week, YEAR(`end`) as year
FROM table
WHERE WEEK(`end`)=24 AND YEAR(`end`)=2016