Questions tagged [sql]

SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

How to get all products from an order including variations via SQL query?

I have searched a lot and hope someone has an answer. I want to run a query in the Wordpress/Woocommerce database and fetch from an individual order, all details, including the variations of a ...
0
votes
1answer
594 views

Randomly select one of last 3 posts

ok so i have this: $args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 1, 'offset' => $offset, ); $q = new ...
1
vote
3answers
6k views

“#1067 - Invalid default value for 'post_date'” when trying to reset AI after backup

I've restored my Wordpress database from an sql backup. However, in doing so, all of the tables have lost auto increment. When I try to add it back in with this sql ALTER TABLE `mercury_posts` ...
0
votes
0answers
9 views

WP_Query adds “(wp_posts.ID = '0')” so no results are returned

I am doing a very simple WP_Query: $query = new WP_Query([ 'pagename' => 'some-post-slug', 'suppress_filters' => true // used by WPML to search in ANY language ]); However, the ...
0
votes
0answers
14 views

SQL query hanging php

I'm having issues with a fairly large WordPress site creating 45+ php-fpm pools. My hosting company says it is some long running SQL queries causing the problem and gave me this: +-----+-------------...
0
votes
1answer
735 views

How to set up prepared query using IN statement

I am a tad bit confused on how I would set up a SQL IN statement using a prepared query. Here is the code: $in = implode(',', array_fill(0, count($product_ids), '%d')); $results = $this->...
3
votes
2answers
3k views

how to get permalink using sql

I am trying to get post title by sql. My sql code is $query ="SELECT wp_posts.post_title AS title , wp_posts.post_content AS content, wp_posts.post_date ...
0
votes
1answer
27 views

I want to run Sql Query in script how can i do this

Thats What I tried But it give console error. i didnt understand how can run this i Have pass jquery variable to sql query but it isnt working <script type="text/javascript"> ...
0
votes
1answer
101 views

How do I get data from my database into my Custom Export Field

I am trying to get data from my database to export to a XML or CSV File by using a custom query. This is my function with the query : <?php function get_workhours($ID){ $sql = $wpdb->...
0
votes
0answers
27 views

Update WooCommerce stock status with SQL query if stock value is greater than 0

I'm attempting to update a large product catalogue using a SQL query via phpMyAdmin if: the _stock_status = onbackorder the _stock > 0 Queries attempted: Update wp_postmeta Set meta_value = '...
0
votes
2answers
31 views

Is my way to change WordPress server is correct?

I'm in the process of changing my web host. I'm wondering about the cleanest way to migrate my WordPress blog. I'm far from being a WordPress expert, I only use it to publish a few posts. Could you ...
0
votes
0answers
16 views

WP Missing first revision with wp_get_post_revisions()

I'm using Wordpress native revisions and I've found a little problem. I want to return a list of revisions to the page however my first published content is lost everytime I make a change. The best ...
0
votes
1answer
1k views

MySQL query for taxonomy-meta

I am working directly with MySQL, using MySQL workbench. Can you help me write a SQL query that will pull all custom taxonomies and their term-meta fields? I have a custom taxonomy called(slug) ...
0
votes
2answers
1k views

How to display a specific category using a custom Query in WordPress?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
0
votes
0answers
15 views

Woocommerce Backend Search by Title and SKU

Good morning, i'm trying to extend backend product search by using this function without success. This snippet works only in Title and i need to add also in Metakey SKU. I have tried extend by using ...
0
votes
1answer
23 views

SQL query to change custom field in Wordpress database

I'm newbie in SQL questions, and today i have a big problem. I need change many fields in my SQL, about 4,5k. But have some rules to the query change, to don't change wrong fields where don't need ...
1
vote
1answer
451 views

Create table from array with prepare

Is it possible to create a table with the wpdb::prepare function? I read the documentation and tried to find examples but there where none that helped me. Even creating a table with prepare doesn't ...
0
votes
1answer
12 views

Bulk find & replace on Wordpress posts/pages (minus image paths)

I'm dealing with a tricky issue and wondering if anyone has a good way to solve this. I am trying to change everything on my Wordpress site that has "2019" in my posts/pages with "2020", however when ...
3
votes
1answer
4k views

Where are image paths to product category images stored in WordPress database

I am using WooCommerce I purposely deleted all my unattached image in media without realizing it was going to delete all product categories images Luckily I have a back up database and all the images ...
0
votes
2answers
1k views

Is it possible to have more than 1 MySQL database in my WordPress blog?

On first launch, WordPress prompts you to input your MySQL database username, password etc. Then I can start working from dashboard. Is it possible for WordPress to have more than one database? If ...
0
votes
2answers
480 views

wpdb LIKE request shows all database data

I would like to get a list of user_nicenames and the ID. But not all the usernames which is what i'm getting now. I understand I should use the % before and after the $name only nothing seems to be ...
1
vote
1answer
2k views

Woocommerce - Changing the order of the upsell products

Having some trouble with a clients site. We have a product with four upsell products linked, and they display on the site. Only problem is, those products are listed on the page in a seemingly random ...
0
votes
2answers
576 views

Where to check in PHPmyAdmin / SQL database for subdomain

After migrating subdomain to new domain, not sure if the subdomain got left over in any of the settings. Where in PHPmyAdmin / SQL database should I find those subdomain urls and update them to the ...
0
votes
0answers
9 views

Get name of all term which is duplicate using Mysql

I am coding something to get all duplicate term which has duplicate name using MySql query. The issue I have currently is I am getting the records in a single occurrence I need all data which has same ...
0
votes
0answers
12 views

dbDelta change PRIMARY KEY

I have a table with a composite primary key (call_id, submission_id). Now, I would like to change the composite primary key (call_id, submission_id, version). The code I am running is similar to the ...
0
votes
0answers
10 views

“Additional CSS” data keeps reverting back to default example, multiple rows in database created

Not really sure the best way to word this. WordPress stores the CSS in Customizer->Additional CSS in the wp_posts table, with the post_type set to 'custom_css' and the post_name set to the theme slug. ...
0
votes
1answer
3k views

Install WordPress with SQL database

I am very new to WordPress. I didn't even know it existed until I had to do it for my work. So I started in with a WAMP server with WordPress. That worked fine until we needed multiple sites with ...
0
votes
1answer
2k views

WooCommerce - Order_itemmeta - Need to add meta_keys to table

I need to add 3 meta values to each order_item to the woocommerce_order_itemmeta table. Any suggestions how to create new meta_keys to be included in the table for all order items?
0
votes
1answer
15 views

How to get products without tag?

Can only with SQL to that? I think with PHP I can do that, taking all product and then taking product with tag and compare those. But can I do that only in 1 line of code by SQL?
0
votes
2answers
483 views

How to run select query of post with category and tags?

I want to fetch multiple posts with categories and tags currently I'm using this query: $pagesize = 20; $pageNumber = 1; $mysql = mysqli_query($con,"SELECT p.post_title, p.ID, p....
0
votes
1answer
454 views

query specific posts according their custom fields, using sql SELECT

My posts have a bunch of custom fields, to help insert and display custom info easily. I am trying to build a search that would select and display posts according values of specific 2 custom fields. ...
0
votes
1answer
896 views

How to handle my row actions on a custom list table in the admin section

I have set up a plugin that because of the amount of data being used I set up a custom table and have extended the WP_List_Table class. I know that is not recommended, but Custom Post Types just won't ...
2
votes
1answer
89 views

Block search SQL from happening

I need to block some accesses to search results not the whole page, just the results. The problem is, I need the search SQL query to not happen AT ALL. (I can conditionaly hide the output loop ...
1
vote
0answers
15 views

Wordpress WPforms customization

Firstly I would like to apologize because my question may be a little bit nooby. For the educational purposes I am building app to keep several different records in DB and then make custom query from ...
0
votes
1answer
527 views

The function is deprecated; use mysql_real_escape_string() instead

I don`t know coding. I recently my website stop to work properly. I get this error on the top of on every page loaded. Deprecated: mysql_escape_string(): This function is deprecated; use ...
1
vote
0answers
23 views

How to verify wp user password by sql query in wp? [closed]

I want to verify the user password without function only by the SQL query.
1
vote
1answer
5k views

Backticks (`) Instead of Single Quotes (') in an SQL Statement?

I have this code which is partially shown here for brevity: global $wpdb; // creates jwp_bids in database if not exists $table = $wpdb->prefix . "jwp_bids"; $charset_collate = $wpdb->...
1
vote
1answer
20 views

Get ALL post ID's export list (Only id's. Php or sql not important )

please help me. I dont know How can I do. I need list all posts IDs. export need 1 3 5 6 7 8 9 . . . . Please help
2
votes
1answer
25 views

SQL User Query by Multiple Roles using PHP

I can successfully get all my WordPress users using the following code: global $wpdb; $sql = 'SELECT * FROM ' . $wpdb->users; $users = $wpdb->get_results( $sql, 'ARRAY_A' ); However, I need to ...
3
votes
2answers
454 views

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class ...
0
votes
0answers
19 views

Slow wordpress search page

When I search on my wordpress (woocommerce) it takes 50 seconds to load. According to Query Monitor the problem is this query. SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON (wp_posts.ID = ...
1
vote
0answers
25 views

How do I run SQL queries on a WordPress web page? [closed]

Whenever I Google this it brings up pages related to Database management. However, I want to run this in the actual webpage. For example: You go to a webpage where you can practice SQL: I.e. you ...
1
vote
1answer
477 views

How can I combine one field using wpdb and group by?

I have the following code in my functions.php where I'm trying to group the quantity sold from woocommerce orders into the variation selected on the product. My query is: $uvuorderposts = $wpdb->...
1
vote
2answers
2k views

Bulk move (or copy) from a custom field to the post content?

I need to move (or copy) the contents of a custom field into the main post body, replacing any existing content. I need to do this for a few hundred posts...Is there a quick way of doing this? I can ...
1
vote
2answers
141 views

How to delete users with no order history through phpmyadmin sql?

I have a wordpress ecommerce website which I have begun to update after not touching it for over a year. The first thing I did was implement reCaptcha into all inquiry and contact forms to reduce the ...
1
vote
1answer
585 views

UPDATE on SELECT results. A SQL query to swap Author with Meta Box value

I inherited a project where, for some reason, the previous developer make a custom post type for authors and a custom select listing all those authors cpt titles in the post edit screen. This led to a ...
0
votes
1answer
738 views

How to optimize multiple insert into wordpress database

I had main file with my plugin and the another file with sql command. In the second file I create two tables and write data to one of them. But I have problem with. In my private computer everything ...
0
votes
1answer
648 views

Update field name without losing the value

So I have this photography website using ACF with flexible content. It has approximately 300 posts. Due to requirements, I need to update the name of some fields. I've tried the following query: ...
0
votes
1answer
813 views

Run an update query in a function

I need to run the below in a function, it updates my database if certain conditions are met. I can't get it to work and I can only assume its because of the "SET @newnum" at the beginning. I've echo'...
3
votes
2answers
3k views

How to remove in the wordpress database all posts revisions except the last three?

here is the commonly recommended sql command for removing posts revisions and cleaning up the wp database: DELETE a,b,c FROM `wp_posts` a LEFT JOIN `wp_term_relationships` b ON (a.ID = b.object_id) ...

1 2 3 4 5 14