spearchilduser Posted March 23, 2012 Share Posted March 23, 2012 hi im currently doign a search on a database but i want it to only show the entries in the database and as some are duplicated they apear more than once for exmaple if house was in the databse 4 times i only want it shown once is this guna be a search but with _rows ? or im really lost any help please Quote Link to comment https://forums.phpfreaks.com/topic/259553-search/ Share on other sites More sharing options...
Adam Posted March 23, 2012 Share Posted March 23, 2012 You can use the "DISTINCT" keyword which will only return rows in the database that are unique - that means every column selected has to have the same values for it to be considered a duplicate (i.e. if the ID is different they won't be considered distinct). You should really fix the problem at the source though, and remove the duplication through a technique known as database normalisation. Quote Link to comment https://forums.phpfreaks.com/topic/259553-search/#findComment-1330465 Share on other sites More sharing options...
spearchilduser Posted March 23, 2012 Author Share Posted March 23, 2012 i would love to format it but its a buit difficult and outta my league in regards to why the data is going in there basically the user can save a option in a table and if they select that option in future then instead of just selecting it it inserts it into the database as new entry so it will be there twice which is why i want to only pull it in the dropbox once if that makes scence Quote Link to comment https://forums.phpfreaks.com/topic/259553-search/#findComment-1330470 Share on other sites More sharing options...
Adam Posted March 23, 2012 Share Posted March 23, 2012 Not quite following what you're saying, but it sounds like you should be normalising the data. It's not difficult, and once you've read about the technique it just makes sense to do it that way. As for your situation though, I don't understand why you would only want to return 1 of the rows? Surely they would all be applicable? Quote Link to comment https://forums.phpfreaks.com/topic/259553-search/#findComment-1330475 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.