chanchelkumar Posted December 10, 2007 Share Posted December 10, 2007 Hi, I am having some datas in my database which is in date wise, i want to sort it removing the repeated phone numbers... Please help me... Quote Link to comment Share on other sites More sharing options...
Dane Posted December 10, 2007 Share Posted December 10, 2007 Post some code please. Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 10, 2007 Author Share Posted December 10, 2007 Actually am getting some values to my database on datewise... i want to pullout these values to a excel sheet without the repeated phone numbers... my coding is not started yet.... i want a guideline to this... how to do this... Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 10, 2007 Share Posted December 10, 2007 You have to tell us the structure of your db and the fields you want to extract ? once we get that information maybe we can help Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 10, 2007 Author Share Posted December 10, 2007 `id` int(10) NOT NULL auto_increment, `startdate` varchar(20) default NULL, `content` longtext, `price` varchar(45) default NULL, `phone` varchar(255) default NULL, `location` varchar(250) NOT NULL default '', `enddate` varchar(20) NOT NULL default 'Null', `category` varchar(255) NOT NULL, `post` varchar(255) NOT NULL, PRIMARY KEY (`id`) this table will upadate datewise... ie new values will enter into this table daily... somtimes the same phone no: will also enter..... tell me if you want more details...(or if am wrong)... Quote Link to comment Share on other sites More sharing options...
kishan Posted December 10, 2007 Share Posted December 10, 2007 Tell me if a record comes with the same ph no u want to display that record or u wnt to eliminate it Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 10, 2007 Author Share Posted December 10, 2007 if a phone number comes in two or more i want it to display only for once... Same as distinct.... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 10, 2007 Share Posted December 10, 2007 You'll want to use SELECT DISTINCT (half way down the page) or perhaps GROUP BY within your SQL query. Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 11, 2007 Author Share Posted December 11, 2007 please get me some code.... i checked it with your link..... Quote Link to comment Share on other sites More sharing options...
samona Posted December 11, 2007 Share Posted December 11, 2007 Theres a keyword called Distinct that you can use. FOr example: select distinct destination from train; Will select only one 'destination' even if it exists more than once in the database. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 11, 2007 Share Posted December 11, 2007 please get me some code.... i checked it with your link..... We're not here to write your code for you, go to the freelance board if that's what you're after. Otherwise, make an honest attempt at writing the code and come back when you get stuck. Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Well Guru... I got stucked and came here for a solution.... I know my codes have some errors.. i tried with dis SELECT distinct content,phone,location,startdate,category,enddate FROM dtmn_url2 where category='$res1' and startdate >='$date3' and startdate <='$date5' and location like '%$location%' But this returns with repeated phone numbers.... Quote Link to comment Share on other sites More sharing options...
p2grace Posted December 12, 2007 Share Posted December 12, 2007 Try using GROUP BY SELECT content,phone,location,startdate,category,enddate FROM dtmn_url2 where category='$res1' and startdate >='$date3' and startdate <='$date5' and location like '%$location%' GROUP BY phone Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Thank you p2grace..... It works.... 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.