简体   繁体   中英

Basic SQl syntax error

I'm trying to write a basic query that changes a "post type" for any posts that contain the word "releases" in their post title.

The query I've written comes up with a syntax error, and I'm uncertain as to where I've gone wrong.

UPDATE TABLE wp_posts SET post_type = "release" WHERE post_title = "%RELEASE%"; 

Change your query to:

UPDATE wp_posts 
SET post_type = 'release' 
WHERE post_title LIKE '%release%'; 

The syntax error comes from the additional "TABLE" keyword, which is not required.

UPDATE wp_posts SET post_type = 'release' WHERE CHARINDEX('RELEASE', post_title) > 0

要么

UPDATE wp_posts SET post_type = 'release' WHERE post_title LIKE '%RELEASE%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM