RedInjection Posted November 1, 2015 Share Posted November 1, 2015 Hello all! I am learning SQL and from what I understand DISTINCT is what I need to hide duplicates? SELECT provider FROM categories ORDER BY provider In my table I have several 'provider' that are duplicates, I don't want to delete them but i just want to hide them, what is the best practice of doing this? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 1, 2015 Share Posted November 1, 2015 DISTINCT, yes. Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 1, 2015 Share Posted November 1, 2015 (edited) If you have duplicate data that pretty much says you have a bad database design. Spend some time studying database normalization. It's not a very complicated subject yet rather important to know. Edited November 1, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 1, 2015 Share Posted November 1, 2015 I'm fairly sure he just meant that the same provider occurs multiple times in the result set. As in: Different categories can share one provider. Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 1, 2015 Share Posted November 1, 2015 (edited) Perhaps, but when dealing with OP's, experience shows Op's are mostly not doing things correctly. Based on this OP's other threads, it just enforces that. I go in for the most part assuming the OP is doing things wrong rather than speculate. OP, if you can post an SQL dump with your tables and sample data we can let you know if you have any issues that need to be addressed. Your DB structure is the foundation of all the code you are going to write to manage it. If your DB is not right, then your code is not going to be right. Right or wrong, at this point in the thread I will assume provider is not a foreign key to the id in the providers table and is likely duplicated text. The only thing that should be in that table is the provider_id. Edited November 1, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.