SQL - 在特定时间(或 ID)后选择新值
我需要 PHP 中的 SQL for MySQL。请查看下表:
| id | ip | time |
| -------------------------------|
| 1 88.207.189.58 1321301482 |
| 2 76.192.849.84 1321301487 |
| 3 65.253.192.46 1321301492 |
| 4 88.207.189.58 1321301522 |
| 5 12.112.221.22 1321301582 |
| 6 65.253.192.46 1321301633 |
| 7 76.192.849.84 1321301657 |
| 8 76.192.849.84 1321301710 |
| 9 12.112.221.22 1321301819 |
我需要选择特定时间后新的 IP
例如:我想选择 time=1321301522 之后的行,但它们应该是新的,它们可能不会在该时间之前出现。在这种情况下,唯一有效的 IP 是 12.112.221.22(第 5 行)。
这是行不通的:SELECT ip FROM table_name WHERE time>1321301522,因为它还会列出非新的。在那之前他们可能没有出现过。
提前致谢!!
I need an SQL in PHP for MySQL. Please view the table below:
| id | ip | time |
| -------------------------------|
| 1 88.207.189.58 1321301482 |
| 2 76.192.849.84 1321301487 |
| 3 65.253.192.46 1321301492 |
| 4 88.207.189.58 1321301522 |
| 5 12.112.221.22 1321301582 |
| 6 65.253.192.46 1321301633 |
| 7 76.192.849.84 1321301657 |
| 8 76.192.849.84 1321301710 |
| 9 12.112.221.22 1321301819 |
I need to select the ip's that are NEW after a particular time
Eg: I want to select rows after time=1321301522 but they should be new, they may not appear before that time. In this case the only valid ip would be 12.112.221.22 (row 5).
This wouldn't work: SELECT ip FROM table_name WHERE time>1321301522 because it would also list the non-new ones. They may not have appeared before that time.
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否是最好的方法,但这是一种方法。
Not sure if this is the best way to do it, but it is one way.