我的 m和我的 s不像我的 rub,因此我希望你能够帮助我。
我的表象是这样:
messages:
id INTEGER PRIMARY KEY AUTO_INCREMENT
to VARCHAR(255)
text text
shown DATETIME
现在,我的文字产生这一部分取决于在线参与者的数量。
"to = STEAM_0:0:xxx OR to = STEAM_0:0:xxy OR to = STEAM_0:0:xxz "
It s a listening of active players and I want to check weather they have some unread messages. Now with that string I can do and a sprintf with this :
SELECT * FROM messages WHERE shown IS NULL AND (%s)"
• 冰层:
SELECT * FROM messages WHERE shown IS NULL AND (to = STEAM_0:0:xxx OR to = STEAM_0:0:xxy OR to = STEAM_0:0:xxz )
NOW 我只有两个问题:
- The sql returns more then 1 entry for every field entry
to
, I would like to return exactly one message for everyto
(LIMIT 1 byto
?) and it has to be the newest (first by id).
为了更清楚地说明这一点,我要假定:
id, to, text
1, "x", "text1"
2, "x", "text2"
3, "y", "text3"
4, "z", "text4"
5, "y", "text5"
6, "z", "text6"
7, "y", "text7"
我要谈以下几点:
1, "x", "text1"
3, "y", "text3"
4, "z", "text4"
- I would like to update the field
shown
within the same SQL call to NOW() for the retrieved entries.