Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Location
    Kepler 62f
    Posts
    14,870

    Valid SQL command for replacement?

    I need to delete some text in table column, but only when another column = a specific value. And by "delete", I mean replace 'something' with '' (nothing).

    This is ONLY to replace:
    Code:
    update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');
    Would adding something as simply as "WHERE" work?

    Code:
    update TABLE_NAME where FIELD_NAME = VALUE set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');
    .... or something like that.

    I think I did this several years go, but have no idea now. Just not something that commonly needed.

    Ideas?
    || Need a good host?
    || See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
    ||

  2. #2
    Join Date
    Oct 2013
    Posts
    5
    Use at your own risk...

    Code:
    UPDATE `someTable`
    SET `someField` = REPLACE(someField, 'someOldTerm', 'someNewTerm')
    WHERE `someOtherField` = 'someValue';

  3. #3
    Quote Originally Posted by TekStorm Inc - James View Post
    Use at your own risk...

    Code:
    UPDATE `someTable`
    SET `someField` = REPLACE(someField, 'someOldTerm', 'someNewTerm')
    WHERE `someOtherField` = 'someValue';
    if the value is fix of other column then use this otherwise use like

  4. #4
    Join Date
    Feb 2006
    Location
    Kepler 62f
    Posts
    14,870
    It's more complicated that I thought ...

    TABLE1 = threads
    TABLE2 = posts

    I need to update posts based on 'forumid', which is only in the threads table, not the posts table. So I need a query that looks at both tables. The tables share the 'threadid' value.

    Two subforums need to have text replaced in all posts.

    I tried writing it myself, but no luck.

    Help?
    || Need a good host?
    || See my Suggested Hosts List || Editorial: EIG/Site5/Arvixe/Hostgator Alternatives
    ||

  5. #5
    Can you post the create table statements for both tables? Or a list of the column names?

  6. #6
    as Jacob is saying you need to post the structure of the tables and then you'll most probably have to do a join between the two tables (quite simple) with your where clause that can be applied on any of the fields of the two tables.

Similar Threads

  1. help me with an sql command
    By imryan in forum Programming Discussion
    Replies: 6
    Last Post: 05-14-2011, 04:08 PM
  2. 503 valid RCPT command must precede DATA driving me insane HELP!
    By lizardhost in forum Hosting Security and Technology
    Replies: 3
    Last Post: 04-20-2007, 06:01 AM
  3. Need SQL command for this
    By Jeff - Exceed in forum Hosting Security and Technology
    Replies: 3
    Last Post: 04-20-2006, 08:07 AM
  4. SQL command Help! List DB
    By DigiCrime in forum Hosting Security and Technology
    Replies: 3
    Last Post: 11-07-2002, 03:50 PM
  5. named.conf string replacement via command line
    By mpope in forum Hosting Security and Technology
    Replies: 3
    Last Post: 05-13-2002, 09:05 AM

Posting Permissions

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