Here is exmaple code,You will change as per your requirement
$wpdb->query(
"
UPDATE $wpdb->posts
SET post_parent = 7
WHERE ID = 15
AND post_status="static"
"
);
Related Posts:
- How to use $wpdb to delete in a custom table
- get_results on large datasets
- Is there a (better) way to access $wpdb results?
- Using $wpdb generates DB error
- How do you use prepare when asking for a list of id’s
- how to execute different sql query in non-sanitized $wpdb->get_results function
- How to update records using $wpdb?
- Need help writing a $wpdb query
- show badge with count for pending items in custom post type
- WP Sql query multiple where clause
- WordPress SQL query – returning ‘true’ ‘false’ or ‘null’
- Modify the structure of data returned by $wpdb
- Syntax for $wpdb->prepare when searching in two columns
- Confused by $wpdb->prepare
- How to display user_nicename and usermeta values by custom query in WordPress?
- Optimizing WordPress Queries – Removing Group By ID
- How can I combine one field using wpdb and group by?
- $wpdb->prepare with ON DUPLICATE KEY UPDATE
- how to use $wpdb->prepare to update a custom table
- WPDB Placeholders and second argument for prepared statements
- Increment integer field in database when WHERE needs to be dynamic [closed]
- Custom SQL query ORDER BY term_order
- Custom $wpdb returns unexpected time based results
- How to left join meta in queries [closed]
- wpdb->get_row is selecting the variable as a column name
- CREATE TABLE with dbDelta does not create table
- $wpdb query outputs php code instead of executing it
- wpdb query not working
- WordPress wpdb->insert returns int(0) => doesn’t insert anything, no errors!
- WPDB SQL Ignore `post_status` Parameter
- how to list all post that are in the custom taxonomy using $wpdb
- WPDB SQL query SELECT from category
- How to use WHERE NOT EXISTS query to avoid duplicate entry using $wpdb to save in custom table?
- Creating an Angular factory from custom database table
- wpdb->update update the entire table instead of one row
- How do I update post based on meta_key in another table?
- How to set up prepared query using IN statement
- Custom database query to validate data
- Alter the main search query to search posts by coauthor user name
- Creates only one table and not the other
- Protect custom form from SQL injection
- looking for a way to allow users to backup the plugin db data(save as)
- SQL Query to select post title & post ID from a particular category
- Get comments after specific date
- query using wpdb in wordpress gets me no result
- Get count of rows based if column exists in two different tables
- query_vars doesn’t return query string (trying to get data from $wpdb)
- WPDB Insert or if exists Update
- How do I check for a duplicate record before inserting using wpdb
- WPDB prepare – like % – placeholders?
- Avoiding “Usage of a direct database call is discouraged”
- passing variables as parameters to stored procedures via wpdb from php-script
- $wpdb->query() multiple query support
- $wpdb Query Result not coming but in phpmyadmin it works [closed]
- wpdb->get_row() / get_results – is it possible to return an object instances of my own class?
- How to email user after inserting the username in database in WordPress
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- How to fetch an array in $wpdb?
- What’s wrong with my $wpdb prepare?
- $wpdb select date range of posts
- Rolling Back from current WordPress version to previous one
- SQL query for custom taxonomy slugs
- Display fields as values in array from external SQL DB
- What is wrong with this wpdb update?
- using $wpdb to insert a form into a post
- wp_create_user not properly entering password
- Problem with creating tables for Plugin
- Foreach loop not working as expected – custom tables and references while submitting a form
- Query insert query executing multiple times
- Undefined offset: 0
- Connect to separate database using $wpdb and authenticate user
- How to access PostgreSQL using WPDB?
- Counting posts with argument without retrieving the posts
- how to assign content to a different author while loading content
- How to pass orderby params to $wpdb->prepare()?
- Register custom table for WP to use in a plugin
- Use $wpdb or other PHP script method to find/replace in WP database
- How to get INSERT errors from $wpdb?
- Display category names on edit user profile using $wpdb
- wpdb and acf via wp rest api
- wpquery properties last_query and last_result : should these be public or private?
- wpdb prepare sql problem
- Query and get meta as object(stdClass) on wp postmeta table?
- wpdb->insert with special chars failing with collation utf8mb4_unicode_520_ci
- SQL queries to another wordpress site
- og:image functions.php
- Show error messages to a user when database insert fails
- Debugging db calls: $wpdb->insert works on test site, not on identical production site
- Combine posts and postmeta
- WPDB delivers wrong results from complex queries
- Include post_status check within $wpdb query
- wpdb get_row database query inquiry
- Depreciated Call -> Function wpdb::escape()
- Inserting and updating rows with wpdb indreases integer fields by 1 point sometimes
- Retrieve a list of users based on some conditions
- wp-postratings: list current user’s unrated posts
- Error inserting row into table
- get only 1 wpdb and get taxonomy, post to next page [closed]
- $wpdb The query does not contain the correct number of placeholders
- $wpdb:insert, more arguements in $format array than in $data