Wednesday, November 2, 2016

SQL: remove all duplicate rows

Delete from <table name> a
where a.rowid > ANY (select b.rowid
                                  from <table name> b
                                  //should include all columns required to be unique
                                   where b.<column name 1> = a.<column name 1>
                                             and b.<column name 2> = a.<column name 2>
                                             and b.<column name 3> = a.<column name 3>

                                             . . . . . .

                                    );

OR

Delete from <table name> a
where exists (select *
                    from <table name> b
                    //should include all columns required to be unique
                     where b.<column name 1> = a.<column name 1>
                      and b.<column name 2> = a.<column name 2>
                      and b.<column name 3> = a.<column name 3>

                        . . . . . .

                       and a.rowid > b.rowid);

---------------------------------------------------------------------------------------------------

                        

If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.


No comments:

Post a Comment