Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1. Guest ji, please consider donating today!   Become a Supporter    ::   Make a Contribution   
    Monthly (Recurring) Target: $300 :: Achieved: $95

Remove Duplicates?

Discussion in 'Information Technology' started by dan, Jul 28, 2006.

  1. dan

    dan
    Expand Collapse
    Guest

    Hi,

    I have a table similiar to this:

    ColA Col B
    100 Dog
    101 Cat
    101 Horse
    102 ouse


    When there is a duplicate in ColA, I want to delete the entire row of
    one of the duplicates and just keep one. Sometimes there might be three
    or four of these, and I just want one. How can i do this? SQL Statement
    or something else?

    Thank you!
     
  2. Loading...


  3. default105

    default105
    Expand Collapse
    Guest

    Sure you could but why is your table field not set up to not allow dulicates
    in this field

    "dan" wrote:

    > Hi,
    >
    > I have a table similiar to this:
    >
    > ColA Col B
    > 100 Dog
    > 101 Cat
    > 101 Horse
    > 102 ouse
    >
    >
    > When there is a duplicate in ColA, I want to delete the entire row of
    > one of the duplicates and just keep one. Sometimes there might be three
    > or four of these, and I just want one. How can i do this? SQL Statement
    > or something else?
    >
    > Thank you!
    >
    >
     
  4. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    I've had a zillon of those

    the simlpest way (if you don't rate the remainder)

    Sub KillDups()
    Dim Db As DAO.Database
    Dim Rs AS DAO.Recordset
    Dim LastKey as string ' in the ex

    Set db = Access.CurrentDb
    Set Rs = Db.OpenRecordset("SELECT DUPKEY FROM MYTABLE",DAO.dbOpenDynsaset)
    While Not Rs.EOF
    If Rs.Fields(0).Value = LastKey Then
    Rs.Delete
    Else
    LastKey = Rs.Fields(0).Value
    End If
    Rs.Movenext
    Wend

    Pieter


    "dan" <itzdan262@gmail.com> wrote in message
    news:1152294464.961883.185660@s16g2000cws.googlegroups.com...
    > Hi,
    >
    > I have a table similiar to this:
    >
    > ColA Col B
    > 100 Dog
    > 101 Cat
    > 101 Horse
    > 102 ouse
    >
    >
    > When there is a duplicate in ColA, I want to delete the entire row of
    > one of the duplicates and just keep one. Sometimes there might be three
    > or four of these, and I just want one. How can i do this? SQL Statement
    > or something else?
    >
    > Thank you!
    >
     
  5. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    I've had a zillon of those

    the simlpest way (if you don't rate the remainder)

    Sub KillDups()
    Dim Db As DAO.Database
    Dim Rs AS DAO.Recordset
    Dim LastKey as string ' in the ex

    Set db = Access.CurrentDb
    Set Rs = Db.OpenRecordset("SELECT DUPKEY FROM MYTABLE",DAO.dbOpenDynsaset)
    While Not Rs.EOF
    If Rs.Fields(0).Value = LastKey Then
    Rs.Delete
    Else
    LastKey = Rs.Fields(0).Value
    End If
    Rs.Movenext
    Wend

    Pieter


    "dan" <itzdan262@gmail.com> wrote in message
    news:1152294464.961883.185660@s16g2000cws.googlegroups.com...
    > Hi,
    >
    > I have a table similiar to this:
    >
    > ColA Col B
    > 100 Dog
    > 101 Cat
    > 101 Horse
    > 102 ouse
    >
    >
    > When there is a duplicate in ColA, I want to delete the entire row of
    > one of the duplicates and just keep one. Sometimes there might be three
    > or four of these, and I just want one. How can i do this? SQL Statement
    > or something else?
    >
    > Thank you!
    >




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4182 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  6. Angus Comber

    Angus Comber
    Expand Collapse
    Guest

    Is there not an SQL statement which can do this?

    Angus

    "Pieter Wijnen"
    <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    ..with.norway> wrote in message news:eXdwucioGHA.516@TK2MSFTNGP05.phx.gbl...
    > I've had a zillon of those
    >
    > the simlpest way (if you don't rate the remainder)
    >
    > Sub KillDups()
    > Dim Db As DAO.Database
    > Dim Rs AS DAO.Recordset
    > Dim LastKey as string ' in the ex
    >
    > Set db = Access.CurrentDb
    > Set Rs = Db.OpenRecordset("SELECT DUPKEY FROM

    MYTABLE",DAO.dbOpenDynsaset)
    > While Not Rs.EOF
    > If Rs.Fields(0).Value = LastKey Then
    > Rs.Delete
    > Else
    > LastKey = Rs.Fields(0).Value
    > End If
    > Rs.Movenext
    > Wend
    >
    > Pieter
    >
    >
    > "dan" <itzdan262@gmail.com> wrote in message
    > news:1152294464.961883.185660@s16g2000cws.googlegroups.com...
    > > Hi,
    > >
    > > I have a table similiar to this:
    > >
    > > ColA Col B
    > > 100 Dog
    > > 101 Cat
    > > 101 Horse
    > > 102 ouse
    > >
    > >
    > > When there is a duplicate in ColA, I want to delete the entire row of
    > > one of the duplicates and just keep one. Sometimes there might be three
    > > or four of these, and I just want one. How can i do this? SQL Statement
    > > or something else?
    > >
    > > Thank you!
    > >

    >
    >
     
  7. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    several ways

    http://support.microsoft.com/default.aspx?scid=kb;en-us;139444

    is one way -> google search: remove duplicates sql
    will also provide other ways

    Pieter


    "Angus Comber" <nospam@gmail.com> wrote in message
    news:e1%23bzbnoGHA.1592@TK2MSFTNGP04.phx.gbl...
    > Is there not an SQL statement which can do this?
    >
    > Angus
    >
    > "Pieter Wijnen"
    > <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    > .with.norway> wrote in message
    > news:eXdwucioGHA.516@TK2MSFTNGP05.phx.gbl...
    >> I've had a zillon of those
    >>
    >> the simlpest way (if you don't rate the remainder)
    >>
    >> Sub KillDups()
    >> Dim Db As DAO.Database
    >> Dim Rs AS DAO.Recordset
    >> Dim LastKey as string ' in the ex
    >>
    >> Set db = Access.CurrentDb
    >> Set Rs = Db.OpenRecordset("SELECT DUPKEY FROM

    > MYTABLE",DAO.dbOpenDynsaset)
    >> While Not Rs.EOF
    >> If Rs.Fields(0).Value = LastKey Then
    >> Rs.Delete
    >> Else
    >> LastKey = Rs.Fields(0).Value
    >> End If
    >> Rs.Movenext
    >> Wend
    >>
    >> Pieter
    >>
    >>
    >> "dan" <itzdan262@gmail.com> wrote in message
    >> news:1152294464.961883.185660@s16g2000cws.googlegroups.com...
    >> > Hi,
    >> >
    >> > I have a table similiar to this:
    >> >
    >> > ColA Col B
    >> > 100 Dog
    >> > 101 Cat
    >> > 101 Horse
    >> > 102 ouse
    >> >
    >> >
    >> > When there is a duplicate in ColA, I want to delete the entire row of
    >> > one of the duplicates and just keep one. Sometimes there might be three
    >> > or four of these, and I just want one. How can i do this? SQL Statement
    >> > or something else?
    >> >
    >> > Thank you!
    >> >

    >>
    >>

    >
    >
     
  8. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    several ways

    http://support.microsoft.com/default.aspx?scid=kb;en-us;139444

    is one way -> google search: remove duplicates sql
    will also provide other ways

    Pieter


    "Angus Comber" <nospam@gmail.com> wrote in message
    news:e1%23bzbnoGHA.1592@TK2MSFTNGP04.phx.gbl...
    > Is there not an SQL statement which can do this?
    >
    > Angus
    >
    > "Pieter Wijnen"
    > <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    > .with.norway> wrote in message
    > news:eXdwucioGHA.516@TK2MSFTNGP05.phx.gbl...
    >> I've had a zillon of those
    >>
    >> the simlpest way (if you don't rate the remainder)
    >>
    >> Sub KillDups()
    >> Dim Db As DAO.Database
    >> Dim Rs AS DAO.Recordset
    >> Dim LastKey as string ' in the ex
    >>
    >> Set db = Access.CurrentDb
    >> Set Rs = Db.OpenRecordset("SELECT DUPKEY FROM

    > MYTABLE",DAO.dbOpenDynsaset)
    >> While Not Rs.EOF
    >> If Rs.Fields(0).Value = LastKey Then
    >> Rs.Delete
    >> Else
    >> LastKey = Rs.Fields(0).Value
    >> End If
    >> Rs.Movenext
    >> Wend
    >>
    >> Pieter
    >>
    >>
    >> "dan" <itzdan262@gmail.com> wrote in message
    >> news:1152294464.961883.185660@s16g2000cws.googlegroups.com...
    >> > Hi,
    >> >
    >> > I have a table similiar to this:
    >> >
    >> > ColA Col B
    >> > 100 Dog
    >> > 101 Cat
    >> > 101 Horse
    >> > 102 ouse
    >> >
    >> >
    >> > When there is a duplicate in ColA, I want to delete the entire row of
    >> > one of the duplicates and just keep one. Sometimes there might be three
    >> > or four of these, and I just want one. How can i do this? SQL Statement
    >> > or something else?
    >> >
    >> > Thank you!
    >> >

    >>
    >>

    >
    >




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4182 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page