deleting duplicate rows

  • thing is, I'm getting syntax errors every time I try via a join

    select u1.*

    FROM cn_users u1

    join cn_users u2 on u1.userid = u2.userid

    and u1.id > u2.id

    returns 227 rows with no problem

    as soon as I try

    delete u1.*

    FROM cn_users u1

    join cn_users u2 on u1.userid = u2.userid

    and u1.id > u2.id

    I get

    incorrect syntax near '*'

    yet this should work, going by everything I've read.

    I've certainly had it working in the past, but can't find the script file at present!

  • delete u1

    FROM cn_users u1

    join cn_users u2 on u1.userid = u2.userid

    and u1.id > u2.id

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Thanks.

    I was sure I'd tried that one, but what the.... it worked.

  • * is required only when you are using SELECT operation.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply