开发者

Obtain all the players born in a particular month in Sqlite

I have a players table which contains the following attributes

_id INTEGER PRIMARY KEY, name text not null,birth_date date not null

I want a query which can give me a l开发者_如何学Cist of all the players born in a particular month say May of 1986.

How could this be achieved? I tried using the date and time functions provided in SQLite but they were of no use.

Any pointers would be appreciated.

Thanks


SELECT p.name, p.birth_date
    FROM Player p
        WHERE p.birth_date > '1986-04-30'
            AND p.birth_date < '1986-06-01';

(untested)


I think this should work. I haven't tried it:

SELECT _id, name, birth_date 
FROM players 
WHERE strftime('%m',birth_date) = '05' AND  strftime('%Y',birth_date) = '1986'


SELECT p.name
     , p.birth_date
FROM Player p
WHERE p.birth_date >= '1986-05-01'
  AND p.birth_date < date('1986-05-01','+1 month') 
;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜