Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>MySQL doesn't have exactly what you're looking for -- yes, there is a <a href="http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace" rel="nofollow"><code>REPLACE()</code></a> string function, but you can't limit it to a single substitution. As such, you might inadvertently replace other occurrences of this constant that could conceivably appear in your title string.</p> <p>IMHO, the easiest way is to find all titles starting with your constant, and just replace the first one (i.e. at the start of the string):</p> <pre><code>UPDATE wp_posts SET post_title = MID( post_title, LENGTH('Constant ')+1 ) WHERE post_title LIKE 'Constant %' AND post_type = 'post'; </code></pre> <p>You need the <code>+1</code> because MySQL string offsets start at 1, not zero.</p> <p>Personally, I always prefer to run the equivalent SELECT first, just to be certain (too many years of MyISAM without <code>BEGIN WORK</code>):</p> <pre><code>SELECT post_title, MID( post_title, LENGTH('Constant ')+1 ) AS replacedTitle FROM wp_posts WHERE post_title LIKE 'Constant %' AND post_type = 'post'; </code></pre> <p>Alternatively, if you're <em>certain</em> that you always want to remove the first word (i.e. up to and including the first space), then the following statement should work:</p> <pre><code>UPDATE wp_posts SET post_title = MID( post_title, POSITION( ' ' IN post_title )+1 ) WHERE post_type = 'post'; </code></pre> <p>Since <code>POSITION()</code> will return zero if no space is found, this statement will be a no-op (i.e. non-destructive) in the general case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload