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
0 answers
37 views

How to short circuit a wordpress query that is not related to posts?

How to short circuit the below query via hooks such that the query is not run based on a condition? I tried using pre_get_posts filter but that is for posts queries only. The query runs as a part of ...
dc09's user avatar
  • 195
0 votes
0 answers
43 views

How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?

On a website with over 1 million posts, the following from class WP_Posts_List_Table __construct() is taking a long time: SELECT COUNT( 1 ) FROM wp_posts WHERE post_type = 'shop_order' AND post_status ...
dc09's user avatar
  • 195
0 votes
0 answers
13 views

SQL query based on two different custom field values

I have custom post type "store" that has two different custom fields: Coutry and City. When in the single country page I list all the stores in that country. What I would like to do is to ...
chaq's user avatar
  • 1
-2 votes
1 answer
65 views

How does wordpress link columns from different tables without using FOREIGN KEY or JOIN?

I can't figure how Wordpress tables has been linked by not using FOREIGN KEY? I tried to understand from this information. For a custom plugin I want to recreate the terms, taxonomy and relationship ...
imagIne's user avatar
  • 41
0 votes
1 answer
27 views

Where is WooCommerce order shipping methods stored

I need to create statistic about shipping methods used. I know that there a method get_shipping_methods() but it takes a very long time to use it with tens of thousands of orders. I would like to ...
Vlado's user avatar
  • 113
0 votes
1 answer
29 views

How to address an invalid "NOT IN ()" query?

Symptoms: In WordPress admin menu we cannot see any pages or products listed any more, even thoguh the pages and products are still accessible through weblinks for example. Tracing the issue: On one ...
Ádám Bukovinszki's user avatar
0 votes
0 answers
40 views

How to correctly cleaning wordpress options table

I want to clean my WordPress site options table using SQL. I'd installed the plugin Performance Lab v2.7.0 by WordPress Performance Team which said that my autoloaded options are making my site slow (...
Nehemoth's user avatar
0 votes
1 answer
74 views

#1067 - Invalid default value for 'post_date' when trying to create a new column

I am trying to create a new column inside the wp_posts table but I am getting the error #1067 - Invalid default value for 'post_date' when I try and save it. What I am trying to do is, I am getting ...
I. Antonov's user avatar
0 votes
0 answers
22 views

Change comments ordering by custom value

I added functionality to vote (up/down) on comments. I store the votes data in a custom table: CREATE TABLE comment_vote ( comment_vote_id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, post_id ...
Abid's user avatar
  • 143
0 votes
1 answer
65 views

SQL phpmyadmin remove posts from cat id exclude condition

I have a sql code for wordpress database that use for deleting posts from specific cat id for specific time duration and I always use this code and it is working fine. DELETE a, -- DELETE from ...
akhbarejadid's user avatar
1 vote
0 answers
38 views

Publishing failed error due to "CAST()" in post

When updating a post about the SQL functions CAST and CONVERT, the post fails to update because I use parentheses after the word "CAST" (ie CAST()). It does not happen if I add parentheses ...
David_Hercules's user avatar
0 votes
1 answer
25 views

updating user in custom wordpress table

I have created a custom table in my wordpress project and I'm using wordpress sql queries to insert/update a user. When an email already exists, it should update the user with the same email, ...
Jan's user avatar
  • 33
0 votes
1 answer
89 views

How to make OR condition in WP_Query

What parameters should be passed to WP_Query to get such sql code? where post_type = "post" or post_author = 123
Валерий Новожилов's user avatar
0 votes
1 answer
20 views

select rows based on exact time (hours, minutes and seconds)

I want to update my wordpress posts based on exact time including hours, minutes and seconds, I tried the simple where clause, it seems ignoring the minutes and seconds, here is my simple query: $date ...
Bill's user avatar
  • 31
0 votes
0 answers
64 views

Want to delete woocommerce coupon in bulk from phpmyadmin based on published date

I want to delete all these woocommerce coupons that's publish date is older than 30 days from current date. I have almost 15K auto generated coupons that needs to be cleared up. From here I got an sql ...
Md. Amanur Rahman's user avatar
0 votes
1 answer
78 views

Firebase with WordPress instead of SQL?

I want to create a WordPress Site with Firebase Database, not SQL, is that possible? and can I do anything like SQL Database (add users, add product, add news, add post and received also...) If that ...
H. Sayouf's user avatar
  • 101
0 votes
1 answer
113 views

Change permalinks in posts via SQL

I have changed our permalink structure for a better SEO Score. Our old was day and name like https://domain.tld/%year%/%month%/%day%/%postname%. On our site are around 2600 posts with links to other ...
Stefan's user avatar
  • 1
0 votes
1 answer
170 views

SQL query to retrieve the number of WordPress posts with all given categories

I'm working on a WordPress blog filter function that shows all categories with posts. When the user clicks a category I want to show the number of posts at each categoryname that have the active ...
phenomenia's user avatar
0 votes
1 answer
71 views

Has the table name in SQL for Wordpress changed from WP_posts to WPCS_post?

I ran this query in SQL in PhyMyAdmin UPDATE wp_posts SET post_content = REPLACE (post_content,'https://www.example.com/wp-content/uploads/','https://www.cdn.example.com/'); Though it ran, then gave ...
Pagula Majorda's user avatar
0 votes
0 answers
65 views

How to sort search result by post_title, then by post_content

How to sort search result by post_title, then by post_content For example - if i search for word "Ball" i want to get results where "ball" exists in title, then the results where &...
0 votes
1 answer
27 views

This SQL request call all time and overload my server : SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'wp_installer_network' AND site_id = 1

I have this SQL request who is call every time on my website and take between 1 and 2 secondes to execute so my serveur break down. What is it and how delete it ? SELECT meta_value FROM wp_sitemeta ...
user1795017's user avatar
0 votes
1 answer
81 views

Possible SQL injection. How to locate and fix?

Google Search Console is saying that certain suspicious URLs in my site are returning a 403 error. They look exactly like this (the links below are not my sites, just examples): https://www....
location's user avatar
0 votes
0 answers
58 views

Deleting the MySQL database

My SQL file has been deleted and I don't have a backup of it, if my WP file exists, how can I create a database for it? Thank you in advance for your help
rohan nikzamir's user avatar
0 votes
0 answers
12 views

Batch Scanning and Deleting Empty WordPress Posts

I found a solution, How To Delete Post's With Empty Content Using WP-CLI. I am Looking For a SQL Query Version That Will Delete All Post's Eith Empty Content. Here Is the WP-CLI Version- wp post ...
damagebrain's user avatar
0 votes
0 answers
111 views

Retrieve data from external database and insert back in

I have some code in my functions.php which inserts from fields into an external database table. and that part works okay. I then want to get the ID of the row I have inserted so I can insert into ...
Luke Crawford's user avatar
0 votes
1 answer
88 views

Group By query based on Custom Field

Hello I have a field name team and I would like to get the total amount that each team has been gatthered Im trying to echo the team name and total amount and group it by team but it doesn't work. ...
Eunice's user avatar
  • 13
0 votes
0 answers
96 views

Use a woocommerce hook to create a table and populate it with a query

In my Wordpress database I created some custom tables. I want to query these tables and display it on a woocommerce item page. Using the code snippet plugin I added a custom html table to the item ...
hacking_mike's user avatar
0 votes
0 answers
17 views

How to change and edit users according to the extension in the URL

I built a nice system that simulates a "battle" when a certain button is pressed, it updates the users' data accordingly, at the moment it works on one step and it is built in a plugin, I ...
kfir ben shimon's user avatar
0 votes
1 answer
62 views

Get count of rows based if column exists in two different tables [closed]

I have two custom tables which both contain a column called reference. wp_invites id lead_name reference 1 John fRgOeRkFeHIm 2 Alex WtRA7T7NFdYW 3 Jason IGr0ZhaCbojD wp_rsvp id accepted ...
Freddy's user avatar
  • 147
0 votes
1 answer
44 views

Merge meta_value's into a single row and then loop

I have a query where I want to merge values from the wp_users and wp_meta tables, including the meta values of a given meta key. This key could have multiple entries. SELECT u.id, (select ...
Colin's user avatar
  • 113
-1 votes
1 answer
251 views

Weird WP -Cli Error Connection Refused

I have a rather of wp-cli problem. I am using wp-cli to import a db from my test server into my staging server and even though the import is successfully and everything seems to be working correctly ...
mjones's user avatar
  • 153
0 votes
1 answer
93 views

Can't send form data to wpdb when URL has query string

I have a table called wp_invites which contains a list of invitees. This table contains a column called reference, which is added to the URL as a query param in order to customise their invite (i.e. ...
Freddy's user avatar
  • 147
0 votes
1 answer
69 views

query_vars doesn't return query string (trying to get data from $wpdb)

I have a ref query string which matches rows in my wp_invites table. In my wp_invites table, I have the following columns: lead_name reference Let's assume here is one of the rows: Lead name: ...
Freddy's user avatar
  • 147
1 vote
1 answer
49 views

3 queries to update WordPress

I have been out of the game for a few years so this is difficult. I remember that there were 3 queries that I used inside CPanel when moving a site. they would update the database name and table ...
Jamie's user avatar
  • 1,363
0 votes
1 answer
2k views

SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta

I have a custom post type called media_coverage and need to export via PHPMyAdmin some of the data in that post type that is in wp_posts (post_title) and also in associated wp_postmeta (meta_key) keys....
BlueDogRanch's user avatar
0 votes
0 answers
128 views

Search results always returns "No results" no matter what

pre_get_posts hook that never works I used the following code both in functions.php of my theme and in my custom plugin in the "after_theme_setup" hook (pre_get_post code only as it is alot ...
Leander's user avatar
0 votes
2 answers
276 views

How to use orderby on meta_value when using Pods custom database table storage

I'm struggling to understand how I can use pre_get_post when the post's metadata is not stored in the wp_postmeta table. I use Pods (https://pods.io) to create custom post types with custom fields, ...
Dan Maby's user avatar
0 votes
1 answer
37 views

WP_Query: How to get results from both meta_key options?

I have the following WP Query: if(isset($_GET['scope']) && !empty($_GET['scope'])) { $scope = $_GET['scope']; } else { $scope = ''; } $foo = new WP_Query([ 'post_type' => '...
Maaverick's user avatar
0 votes
0 answers
99 views

how to delete in phpmyadmin sql - all users with certain condition and all dependencies

I have in my wordpress website a bunch of pages that has mydomain.com/author/gertielamrertyk/ can someone help me create an sql that will delete all users with certain condition (in my case it is a ...
Axil's user avatar
  • 61
0 votes
1 answer
233 views

Wordpress can I manually add columns in users table and display it in the default manage user plugin and registration form? [closed]

How would I go about doing this? Thank you!
sorce's user avatar
  • 1
0 votes
1 answer
173 views

dynamic page using php from sql database

The Problem I am really struggling to get wordpress to generate a page dynamically based on the content of a database. The Context I have a sql database which contains unique slugs and Ids, and I am ...
Yenmangu's user avatar
0 votes
0 answers
49 views

Sql query does not work well

I have a problem with a SQL query in wordpress. I create a query that return product_ID of products that have one or more attribute. I have highlighted my problem. I want to displya the product that ...
Simone Franceschetti's user avatar
1 vote
0 answers
20 views

WordPress is not creating table in database after activating plugin,

I struggled with this a long time! Can anyone help me? My plugin is not creating a database table once activated. The following code is in the main plugin file. function woocq_activate() { global ...
Mushy's user avatar
  • 11
0 votes
1 answer
109 views

custom tables in wordpress Database? (can i just create them with sql?)

i just want to create a custom Table in my WordPress database and i saw many php functions to deal with that my question now is : can i just create them with an sql command and for what do i need to ...
DougPilatus's user avatar
0 votes
0 answers
578 views

SQL query - get a featured image's alt / alternative text

I am writing some SQL queries to get post data out of a database for certain posts (so WP functions are not an option). I am trying to get post IDs, post URLs, post featured image URLs and associated ...
Anthony's user avatar
  • 31
0 votes
1 answer
66 views

REGEXP_REPLACE in post_contet

So, basically, I want to remove trailing slashes from specific domain urls. For example: https://www.example.com/here/postname/ into https://www.example.com/here/postname I have 10.4.21-MariaDB which ...
Ivana Kruljac's user avatar
0 votes
1 answer
824 views

How to left join meta in queries [closed]

I have a query something like //read products with thumbnail and sku SELECT products.*, pm1.meta_value as sku, p1.guid as thumbnail FROM `wp_posts` as products LEFT JOIN `wp_postmeta` as pm1 ...
Leo's user avatar
  • 121
-1 votes
1 answer
394 views

wpdb prepare without placeholder

Recently, I found out why there are a lot of PHP Notice on my debug.log. It is because of wpdb:prepare needing placeholders. Documentation says that I need to do: $wpdb->get_results( $wpdb->...
Mr. Kenneth's user avatar
0 votes
1 answer
53 views

Sql formatting for post data within function

I'm calling a function through ajax in my site, and within the function that's being hit I'm taking the data (in this case it's a search term) and putting it into LIKE statements in sql: $...
Geoff_S's user avatar
  • 113
0 votes
2 answers
321 views

Wordpress SQL LIKE request doesn't work for fields with special symbols

In WordPress I make SQL-requests to the database but LIKE request doesn't work correctly. Actial value of meta_value field in the database is such string: a:1:{i:0;s:9:"full-time";} if I ...
Kir Mazur's user avatar
  • 111

1
2 3 4 5
17