使用MIN()函数删除查询

时间:2014-04-03 12:19:39

标签: mysql

我对此查询有疑问:

我想删除用户名 upload_time 特定的记录。

这是我的查询:

DELETE FROM [upload_news] 
WHERE (SELECT MIN[upload_time] 
FROM [upload_news] 
WHERE [username]='"+username+"');

我该如何做到这一点?

1 个答案:

答案 0 :(得分:1)

像这样改变

DELETE FROM [upload_news] WHERE upload_time=
(SELECT min(upload_time) FROM [upload_news] WHERE 
 [username]='"+username+"')