开发者

mysql subquery in single table

I have 2 columns in an "entries" table: a non-unique id, and a date stamp (YYYY-MM-DD). I want to select "all of the entry id's that were inserted today that have never been entered before."

I've been trying to use a subquery, but I don't think I'm using it right since they're both performed on the same table. Coul开发者_运维问答d someone help me out with the proper select statement? I can provide more details if need be.


Disclaimer: I don't have access to a mysql database right now, but this should help:

select
  e.id
from
   entries e
where
   e.date = curdate() and
   e.id not in
     (select id from entries e2 where e2.date < e.date)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜