Solved

Erase some values in a field, leave the rest alone

Posted on 2013-01-04
2
223 Views
Last Modified: 2013-01-08
I have a table with a field called 'Website'

Some of the info is entered like this:  google.com

Some of it like this:  www.google.com

and Some like this: http://www..google.com

How can I parse all the fields so that all the records will all show the domain.com only, erasing  the rest?

Thanks
0
Comment
Question by:Rush_2112
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 38745837
Try:
UPDATE `tblWebsite` SET `Website`= SUBSTRING(`Website`,8) WHERE SUBSTRING(`Website`,1,7)='http://'

Open in new window

followed by
UPDATE `tblWebsite` SET `Website`= SUBSTRING(`Website`,5) WHERE SUBSTRING(`Website`,1,4)='www.'

Open in new window

Note that not all websites are configured to work without www.
0
 
LVL 1

Author Closing Comment

by:Rush_2112
ID: 38756046
Worked perfectly, thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Creating and Managing Databases with phpMyAdmin in cPanel.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now