Title: MySQL WordPress Database concat help needed
Last modified: August 19, 2016

---

# MySQL WordPress Database concat help needed

 *  [JaneLitte](https://wordpress.org/support/users/janelitte/)
 * (@janelitte)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/)
 * I’ve screwed up my database a bit in terms of the permalinks. I didn’t really
   think through what would happened when I changed the post_name to match the changes
   to the post_title.
 * What I would like to do is change all of the posts after 8/30/07 to start with“
   revew-” in the post_name field and all the posts before 8/30/07 to not start 
   with “review-“
 * I know how to effectuate the last issue:
 * UPDATE `wp_posts` SET post_name = replace( post_name, ‘review-‘, ” ) WHERE post_modified
   < 2007-08-30
 * It’s the first part that I have issue with. Concat appends the data and I want
   to insert it at the beginning of the field.
 * UPDATE `wp_posts` SET `post_name` = CONCAT(`post_name`, ‘review-‘) WHERE post_modified
   > 2007-08-30

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675434)
 * Reverse post_name and ‘review-‘ in your CONCAT:
 * `CONCAT('review-', post_name)`
 * By the way, you do understand the point of a _permalink_ and the use of the post_name
   in it, yes? `:)`
 *  Thread Starter [JaneLitte](https://wordpress.org/support/users/janelitte/)
 * (@janelitte)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675506)
 * Well, my understanding is that permalink is what sets the post name, correct?
   and by manually changing the post_name, I was affecting the links to the site,
   right?
 *  [Charles E. Frees-Melvin](https://wordpress.org/support/users/thee17/)
 * (@thee17)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675507)
 * the permalink is set by the post slug, which unless specified gets set by the
   post title.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675508)
 * The post slug (post_name) is generated _from_ the post title, and is (typically)
   assigned as the endpoint for the permalink, assuming of course one is using %
   postname% in their permalink structure.
 * My point about the permalink is that, by changing the post_name you do alter 
   the url to a post, which means any such post now provides a potentially broken
   link if *anyone* has ever linked to it using the original url. This includes 
   search engines, directories, etc.
 *  Thread Starter [JaneLitte](https://wordpress.org/support/users/janelitte/)
 * (@janelitte)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675514)
 * Right – and I didn’t really understand that until I changed it, checked my stats
   and noticed all these broken links. But there was a definitive date in which 
   I started using “REVIEW” in my titles so my plan is to strip out review from 
   all the post slugs(post_name) and then add it back in to all posts after 8/30/
   2007.
 * The concat sql query was my attempt at that. Before I undertake that route, let
   me know if I am incorrect.
 * I thought about making a 301 redirect, but I don’t think that it can be done 
   or at least I can’t think of how it would be done.
 * It would have to be a conditional one – i.e., if the link coming in is prefaced
   with review then strip out the characters “review-” but that seems pretty complicated
   if I can accomplish the same task with two simple sql queries.
 * Please let me know though if I am not doing this right.
 *  [Charles E. Frees-Melvin](https://wordpress.org/support/users/thee17/)
 * (@thee17)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675515)
 * when linking internally using the page id like [http://domain.net/?page_id=14](http://domain.net/?page_id=14)
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675530)
 * Can’t help on the redirects; and url rewrites through .httaccess is not one of
   my areas of expertise.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘MySQL WordPress Database concat help needed’ is closed to new replies.

## Tags

 * [concat](https://wordpress.org/support/topic-tag/concat/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 7 replies
 * 3 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/mysql-wordpress-database-concat-help-needed/#post-675530)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
