鍍金池/ 問答/數(shù)據(jù)庫/ 數(shù)據(jù)庫查詢問題:沒有 id 的數(shù)據(jù)表,如何根據(jù) date 的最小值進行數(shù)據(jù)修改?

數(shù)據(jù)庫查詢問題:沒有 id 的數(shù)據(jù)表,如何根據(jù) date 的最小值進行數(shù)據(jù)修改?

項目中想進行一個數(shù)據(jù)的更新,但那個數(shù)據(jù)表是沒有主鍵 ID 的,我想要的就是以 date 字段作為條件,取到最早的數(shù)據(jù)(每個類有十條數(shù)據(jù))然后進行更新,MySQL 語句該如何寫才正確呢?我嘗試過寫:
update table_name set tid=2 where platform="hitbtc" and coin="zrx" and date = (select min(date) from table_name where platform="hitbtc" and coin="zrx") limit 1;
但是 mysql 提示并不能進行修改。

回答
編輯回答
故林

不能同時進行更新和查詢操作,兩個查詢時可以的,這兩步要分開寫。

2017年2月17日 12:58