SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: How can I create this table?
-
Jan 15, 2006, 15:05 #1
- Join Date
- Dec 2005
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How can I create this table?
Hello,
I have 2 tables that I need to make into one.
This first table is called mct, contains all the products name, ids, descriptions, etc. The problem with this table is that it was built using a feed and contains many duplicate products.
The second table, mct2, contains only the product names but there are no duplicates.
Okay, so how can I make this one nice, neat table without the duplicates. Or how can I delete the duplicates from the first table? I have tried building a table using a select/ distinct statement but can't get it figured out.
Thanks
-
Jan 15, 2006, 15:09 #2
- Join Date
- Feb 2004
- Location
- Huldenberg (Belgium)
- Posts
- 426
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
why don't you make a SELECT query where you look for the id's of all the products with the same product name.
Then you do a DELETE query for all the id's except one...The Path of excess leeds to the tower of wisdom (W. Blake)
-
Jan 15, 2006, 15:22 #3
- Join Date
- Dec 2005
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi, I have tried something similar with the following:
SELECT mctid FROM `mct`, mct2 WHERE mct_title= mct2_title
This just gives me all the products in the table. I am not really sure how to write the select statement to get just the ones that have matching names.
-
Jan 15, 2006, 15:22 #4
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
please do a search in the Databases forum, we've answered the "how do i remove all duplicates except one" several times
-
Jan 15, 2006, 16:33 #5
- Join Date
- Dec 2005
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the replies, I really appreciate it.
I was able to accomplish it by deleting the duplicates from table mct like so:
Code:delete from mct group by mct_title having count(*) > 1
-
Jan 15, 2006, 16:37 #6
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
Originally Posted by affmark
-
Jan 15, 2006, 17:09 #7
- Join Date
- Dec 2005
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, I did. Sorry, I should have mentioned that in the above post.
Bookmarks