View Single Post
Join Date: Apr 2008
Posts: 296
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: Remov duplicates from array

 
0
  #5
Dec 5th, 2008
then you do like this...example
  1. CREATE TABLE table2 (
  2. id INT NOT NULL UNIQUE AUTO_INCREMENT,
  3. name VARCHAR(20) NOT NULL
  4. );
  5.  
  6. INSERT INTO table2(id,name) VALUES
  7. (1,'Things Fall Apart'),
  8. (2,'Things Fall Apart'),
  9. (3,'The Famished Road'),
  10. (4,'Things Fall Apart'),
  11. (5,'The Famished Road'),
  12. (6,'Thirteen cents'),
  13. (7,'Thirteen cents');
  14.  
  15. CREATE TABLE
  16. temp2(id VARCHAR(10), name VARCHAR(20))
  17. TYPE=HEAP;
  18.  
  19. INSERT INTO temp2(name) SELECT DISTINCT name FROM table2;
  20.  
  21. DELETE FROM table2;
  22.  
  23. INSERT INTO table2(id,name) SELECT id,name FROM temp2;

you can place your data in temp table..and display main table without duplication of data by using DISTINCT .....
Last edited by Aamit; Dec 5th, 2008 at 9:05 am.
Reply With Quote