vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have a table containing web site host names, most of them having both a "name.com" and "www.name.com" version, that I'd like sorted in the following manner: axxx.com www.axxx.com bxxx.com www.bxxx.com wxxx.com www.wxxx.com zxxx.com www.zxxx.com Any way to do this? |
| |||
| On 24-nov-2007, at 0:29, Jim wrote: > I have a table containing web site host names, most of them having > both a "name.com" and "www.name.com" version, that I'd like sorted > in the following manner: > > axxx.com > www.axxx.com > bxxx.com > www.bxxx.com > wxxx.com > www.wxxx.com > zxxx.com > www.zxxx.com > > Any way to do this? > Sure, just create a extra sort column, and fill it with the original names after you stripped of the parts before the second dot, counting from the right. I'd first count the number of dots to decide wich fields have to be altered. Then, based on the number of dots, calculate the position of the one but last dot and do a substring on the field. Then sort based on that new column. HTH Peter |
| |||
| Hi Jim it seems that you cannot create an index with a function soyou will need toestablish a separate 12 character column which has all of the URL entries insertedalphabetically in ascending order (fully padded with www. prefix)backup your DBALTER TABLE table ADD TwelveCharacterURL CHAR(12), ADD FOREIGN KEY 12CharacterIndex (TwelveCharacterURL); UPDATE TABLE TABLE set TwelveCharacterURL=(LPAD(OldURLColumn,12,'www.')); Anyone else? Martin ______________________________________________Disc laimer and confidentiality noteEverything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.> From: jj@zolx.com> To: mysql@lists.mysql.com> Subject: Unusual sort> Date: Fri, 23 Nov 2007 16:29:50 -0700> > I have a table containingweb site host names, most of them having both a > "name.com" and "www.name..com" version, that I'd like sorted in the > following manner:> > axxx.com>www.axxx.com> bxxx.com> www.bxxx.com> wxxx.com> www.wxxx.com> zxxx.com> www.zxxx.com> > Any way to do this? > > > -- > MySQL General Mailing List> For list archives: http://lists.mysql.com/mysql> To unsubscribe: http://lists..mysql.com/mysql?unsub=mgainty@hotmail.com> __________________________________________________ _______________ Your smile counts. The more smiles you share, the more we donate.* Join in. http://www.windowslive.com/smile?oci...ilewlhmtagline |
| ||||
| Hi, One thought, it might a good idea to make a trigger/procedure that inserts the seprate index field, so you can forget about it from here on. -----Original Message----- From: Martin Gainty [mailto:mgainty@hotmail.com] Sent: Saturday, November 24, 2007 11:18 AM To: Jim; mysql@lists.mysql.com Subject: RE: Unusual sort Hi Jim it seems that you cannot create an index with a function soyou will need to establish a separate 12 character column which has all of the URL entries insertedalphabetically in ascending order (fully padded with www. prefix)backup your DBALTER TABLE table ADD TwelveCharacterURL CHAR(12), ADD FOREIGN KEY 12CharacterIndex (TwelveCharacterURL); UPDATE TABLE TABLE set TwelveCharacterURL=(LPAD(OldURLColumn,12,'www.')); Anyone else? Martin ______________________________________________Disc laimer and confidentiality noteEverything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.> From: jj@zolx.com> To: mysql@lists.mysql.com> Subject: Unusual sort> Date: Fri, 23 Nov 2007 16:29:50 -0700> > I have a table containing web site host names, most of them having both a > "name.com" and "www.name.com" version, that I'd like sorted in the > following manner:> > axxx.com> www.axxx.com> bxxx.com> www.bxxx.com> wxxx.com> www.wxxx.com> zxxx.com> www.zxxx.com> > Any way to do this? > > > -- > MySQL General Mailing List> For list archives: http://lists.mysql.com/mysql> To unsubscribe: http://lists.mysql.com/mysql?unsub=mgainty@hotmail.com> __________________________________________________ _______________ Your smile counts. The more smiles you share, the more we donate.* Join in. http://www.windowslive.com/smile?oci...ilewlhmtagline |