I have a mysql database xxl_wordpress
with a table wp_posts
the has a field post_content
post_content
contains imported HTML pages.
I am trying to remove everything before the <body>
tag within the content of that field for each record.
Is there an SQL query that will do this? I tried searching for it but was not able to find it.
Try using the following :
USE xxl_wordpress
UPDATE `wp_posts`SET `post_content` = MID(`post_content`, locate('<body', `post_content`))
Notice I didn't close the body tag. This way if the <body>
tag has attributes (e.g. <body class="maintext"
), it will still work.