Getting tricky with adding text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TVining
    New Member
    • Dec 2007
    • 26

    Getting tricky with adding text

    I need to add "FOR IMMEDIATE RELEASE." to all of my records.

    I know I can use ConCat, but approximately 75% of my records contain some HTML at the beginning for formatting. I need to add the statement to the Beginning of the text (after </DEV>) or at the beginning of the record, whichever is closer.

    So, a record without HMTL will be:
    "FOR IMMEDIATE RELEASE.
    Private John G dough has graduated...... "

    And with will be:
    "<PHOTO>
    FOR IMMEDIATE RELEASE.
    Private Gina I Jane has graduated...... "

    Is there an easy way to say "look for </DEV>" and if not, do it anyways?

    The reason is this: I later pull my title from everything after "RELEASE. " and before "HAS GRADUATED"

    Thanks!
    Tony
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by TVining
    I need to add "FOR IMMEDIATE RELEASE." to all of my records.

    I know I can use ConCat, but approximately 75% of my records contain some HTML at the beginning for formatting. I need to add the statement to the Beginning of the text (after </DEV>) or at the beginning of the record, whichever is closer.

    So, a record without HMTL will be:
    "FOR IMMEDIATE RELEASE.
    Private John G dough has graduated...... "

    And with will be:
    "<PHOTO>
    FOR IMMEDIATE RELEASE.
    Private Gina I Jane has graduated...... "

    Is there an easy way to say "look for </DEV>" and if not, do it anyways?

    The reason is this: I later pull my title from everything after "RELEASE. " and before "HAS GRADUATED"

    Thanks!
    Tony
    But in your sample data, you show it as after <PHOTO>?

    You want the text to be inserted after <PHOTO> or after </DEV>?

    Comment

    • TVining
      New Member
      • Dec 2007
      • 26

      #3
      Originally posted by amitpatel66
      But in your sample data, you show it as after <PHOTO>?

      You want the text to be inserted after <PHOTO> or after </DEV>?
      </DEV>

      sorry. I was using that as an example. <photo> meant that is where the photo appears when the record is displayed.

      Tony

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Originally posted by TVining
        </DEV>

        sorry. I was using that as an example. <photo> meant that is where the photo appears when the record is displayed.

        Tony
        I will suggest you to use two different updates as shown below:

        [code=sql]

        UPDATE table1 SET column1 = CONCAT('FOR IMMEDIATE RELEASE',column 1) WHERE INSTR(column1, '</Dev>') = 0
        /

        UPDATE table1 SET column1 = CONCAT(SUBSTRIN G(column1,1,INS TR(column1,'</DEV>') + 6),' FOR IMMEDIATE RELEASE ',SUBSTRING(col umn1,INSTR(colu mn1,'</DEV>') + 6)) WHERE INSTR(column1,' </DEV>') > 0
        /

        [/code]

        Comment

        • TVining
          New Member
          • Dec 2007
          • 26

          #5
          Thanks!

          Okay, I get it. Thanks!!
          Last edited by TVining; Mar 12 '08, 05:16 PM. Reason: Figured it out

          Comment

          Working...