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

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

項(xiàng)目中想進(jìn)行一個(gè)數(shù)據(jù)的更新,但那個(gè)數(shù)據(jù)表是沒有主鍵 ID 的,我想要的就是以 date 字段作為條件,取到最早的數(shù)據(jù)(每個(gè)類有十條數(shù)據(jù))然后進(jìn)行更新,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 提示并不能進(jìn)行修改。

回答
編輯回答
故林

不能同時(shí)進(jìn)行更新和查詢操作,兩個(gè)查詢時(shí)可以的,這兩步要分開寫。

2017年2月17日 12:58