如何删除SQL查询中的重复条目? [英] How can I remove duplicate entries in a sql query?
本文介绍了如何删除SQL查询中的重复条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据库被命中服务器上的程序填充。
问题是每个客户端连接可能需要点击一下1-2
第二时间框架。这导致多个数据库条目 -
完全相同,除了event_id字段,这是
自动编号。
我需要一种方法来查询重复的记录。也就是说,任何
记录完全相同,除了event_id应该只返回一条记录。
这可能吗?
谢谢,
巴里
I have a database being populated by hits to a program on a server.
The problem is each client connection may require a few hits in a 1-2
second time frame. This is resulting in multiple database entries -
all exactly the same, except the event_id field, which is
auto-numbered.
I need a way to query the record w/out duplicates. That is, any
records exactly the same except event_id should only return one record.
Is this possible??
Thank you,
Barry
推荐答案
试试这个,未经测试: - )
SELECT *
FROM table1 a,
(SELECT min(id)FROM table1)AS b
WHERE a.id = b.id
BarrySDCA写道:
try this, not tested :-)
SELECT *
FROM table1 a,
(SELECT min(id) FROM table1) AS b
WHERE a.id = b.id
BarrySDCA wrote:
我有一个数据库被命中服务器上的程序填充。
问题是每个客户端连接可能需要在1-2秒的时间内进行几次点击。这导致多个数据库条目 -
完全相同,除了event_id字段,它是自动编号的。
我需要一种方法来查询记录w /重复。也就是说,除了event_id之外,任何
记录都应该只返回一条记录。
这可能吗?
谢谢,
Barry
I have a database being populated by hits to a program on a server.
The problem is each client connection may require a few hits in a 1-2
second time frame. This is resulting in multiple database entries -
all exactly the same, except the event_id field, which is
auto-numbered.
I need a way to query the record w/out duplicates. That is, any
records exactly the same except event_id should only return one record.
Is this possible??
Thank you,
Barry
hrm ....没有运气。我跑了这个:
来自`playback_log`的SELECT *,(SELECT min(EVENT_ID)FROM
`playplay_log`)AS b WHERE.EVENT_ID = b.EVENT_ID
你能看到什么吗?我很感激帮助。谢谢
hrm....no luck. I ran this:
SELECT * from `playback_log` a,(SELECT min(EVENT_ID) FROM
`playback_log` ) AS b WHERE a.EVENT_ID = b.EVENT_ID
Can you see anything? I appreciate the help a bunch. thank you
Haven没有测试过这个:
SELECT *
FROM playback_log a
WHERE a.event_id =(从playback_log中选择min(event_id)b
其中a.field1 = b.field1)
;
您需要列出所需数量的字段,以匹配子选择的
where子句中的相同行。
托马斯
BarrySDCA写于06.03.2006 00:33:
Haven''t tested this:
SELECT *
FROM playback_log a
WHERE a.event_id = (select min(event_id) from playback_log b
where a.field1 = b.field1)
;
You will need to list as many fields as need to match the identical rows in the
where clause of the sub-select.
Thomas
BarrySDCA wrote on 03.03.2006 00:33:
hrm ....没有运气。我跑了这个:
SELECT *来自`playback_log` a,(SELECT min(EVENT_ID)FROM
`playback_log`)AS b WHERE.EVENT_ID = b.EVENT_ID
你能看到什么吗?我很感激帮助。谢谢
hrm....no luck. I ran this:
SELECT * from `playback_log` a,(SELECT min(EVENT_ID) FROM
`playback_log` ) AS b WHERE a.EVENT_ID = b.EVENT_ID
Can you see anything? I appreciate the help a bunch. thank you
这篇关于如何删除SQL查询中的重复条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文