Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Question Use wildcard find and place segment of field in another field?

    I'm wondering if it's possible to take part of a field information and insert it into another field?

    I have a column called "idata" and some of the fields contain a segment of html data involving width="*px". It doesn't really say *, it's actually a number, but not every field has the same number.

    I'd like to be able to use a sort of wild card, and say find the 'width="*px"' in the idata column and then put just the number in another field called in the imgwidth column, and replace the former number in idata with ''?

    Is this possible? Otherwise I have to go through 550 rows, one at a time.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    You could use LIKE % check for it.

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Can that work in a replace statement? To say find where like 'width="%"' and insert % into another field?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    No, you can't use backreferences with replace. What you could do is loop through the rows, match/replace your string with a regular expression(preg_replace()), and update the row.

  • #5
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Forgetting the wild card stuff, how would I go about saying 'find the phrase ("Created by Gareth") in this field, and insert ("Gareth") into another field'?

    Nevermind, I remembered an UPDATE command can do this.
    Last edited by TwilightRealm; 01-31-2009 at 09:56 PM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •