我在嘗試查找所有最後修改日期大於2015-03-01並且名稱列爲空的條目。 這是我寫的mySQL錯誤1064:澄清
SELECT * FROM `inventory` where date(date_modified) >= date '2015-03-01' AND where name is not null ORDER BY `inventory`.`date_modified` DESC
我得到錯誤1064當我嘗試運行此查詢的查詢。
我在嘗試查找所有最後修改日期大於2015-03-01並且名稱列爲空的條目。 這是我寫的mySQL錯誤1064:澄清
SELECT * FROM `inventory` where date(date_modified) >= date '2015-03-01' AND where name is not null ORDER BY `inventory`.`date_modified` DESC
我得到錯誤1064當我嘗試運行此查詢的查詢。
您需要圍繞參數date
的圓括號。此外,在AND
之後,您不會重複WHERE
關鍵字。
SELECT * FROM `inventory`
where date(date_modified) >= date('2015-03-01')
AND name is not null
ORDER BY `inventory`.`date_modified` DESC
你的描述,你說
名稱的列是空
您的查詢你說:
其中名稱不爲空
哪一個是正確的?
由於您的查詢有兩次使用WHERE
,因此您的查詢語法錯誤,您正在獲得。
SELECT ...WHERE .... AND WHERE
這是這樣做的。請更改爲空或不爲空取決於你想要什麼
SELECT
*
FROM
inventory
WHERE
date(date_modified) >= date('2015-03-01') AND name is null -- is not null
ORDER BY inventory.date_modified DESC
我的意思是名字欄已滿。我很抱歉的混淆。我正在嘗試學習mySQL。 – Ria 2015-03-03 22:49:19
不用擔心。我們都在學習。你試過我的選擇嗎?如果您遇到問題/錯誤,請告訴我。 – 2015-03-03 23:41:46
'日期(DATE_MODIFIED)> =日期 '2015-03-01''可以簡化爲'DATE_MODIFIED> =' 2015-03-01'' – 2015-03-03 01:50:29