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).
273
questions with no upvoted or accepted answers
0
votes
0
answers
40
views
Customising the default wordpress search functionality
I find the current from WordPress too strict as it doesn't allow for some minor spelling mistakes. How can I edit this function?
I was checking out pre-get-posts however I don't think that allows me ...
0
votes
1
answer
50
views
Run a sql (update) after 12 hours after the user login. Woocommerce users
How can I Run a sql (update) after 12 hours after the user login (for Woocommerce users)
After 12 hours after a user login, I want to run a sql/ function to update a value in the database.
To set a ...
0
votes
2
answers
1k
views
Display data from phpMyAdmin with WordPress
I have imported my website to Wordpress and facing a big issue how can I do sql Query to display data on my pages with wordpress?
for example I have product, price, description which I need to display ...
0
votes
0
answers
167
views
How delete post_content records of specific category from phpmyadmin
I need a SQL command to delete post_content records for specific category's posts
0
votes
0
answers
195
views
Creating multiple tables with Plugin
I opened a new question, just to be sure. The former request has partly been resolved.
I got another question regarding creating tables for wordpress: Only one table is created (The first one), but ...
0
votes
0
answers
81
views
Removing Malware
I've been asked to remove some Malware from a friend's site.
I've found some wonky links in the wp_postmeta table, but the post_id that the field is associated with doesn't exist - and, weirdly, it's ...
0
votes
0
answers
67
views
WP Query - grouping posts by same meta key, adding together values from another key
I'm attempting to create a leaderboard for 8 teams that will play multiple games and earn different amount of points for each game.
The setup will be pulling entries from a custom post type game, ...
0
votes
0
answers
68
views
Custom User registration system
before asking this question I have been checking out other questions but still could find an answer. Please don't mind if I ask a silly question.
The situation:
I would like to build a user ...
0
votes
0
answers
276
views
Lock wait timeout exceeded; try restarting transaction
I get the bottom error in the debug file. I don't know how can I solve it!
خطای Lock wait timeout exceeded; try restarting transaction در پایگاهداده وردپرس برای دستور INSERT INTO `wp_options` (`...
0
votes
0
answers
64
views
Search results sort order failing: set by date only
Hi the default wordpress search seems to be for "piano"
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND (((wp_posts.post_title LIKE '%piano%')
OR (wp_posts.post_excerpt ...
0
votes
0
answers
149
views
I wanted to Know that how can I give ingore to 0000-00-00 in my config file
I wanted to know that how can I give ignore to 0000-00-00 in my config file so that I didn't get an error of invalid value for this Zero-Date 0000-00-00 in my site database.
0
votes
0
answers
31
views
How to use Multi SQL Database in Wordpress?
It is my wp-config.php of Wordpress site.
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use ...
0
votes
0
answers
86
views
Querying terms with calculations based on term meta data, sql vs. get_terms
Is it viable and or advisable to try and implement a query like the below through get_terms and its meta query functionality?
Basically, I query terms of a specific taxonomy 'pr' that have meta fields ...
0
votes
0
answers
269
views
Any way to use FETCH_KEY_PAIR with $wpdb?
I'm trying to get key/value pair results from a query like PDO's FETCH_KEY_PAIR from a $wpdb query. The closest I found was the OBJECT_K output from get_results(). But that returns the key, but for ...
0
votes
0
answers
28
views
how to list all post that are in the custom taxonomy using $wpdb
global $wpdb;
$custom_post_type = 'post'; // define your custom post type slug here
// A sql query to return all post titles
$results = $wpdb->get_results( $wpdb->prepare( "SELECT ID, ...
0
votes
1
answer
301
views
Display a number value from mysql query in WP
Anyone have a suggestion on how I can display the result of a SQL query in a WP post or page? The query statement is a SUM statement and I want to only display the resulting number value on the page. ...
0
votes
1
answer
108
views
WP_query has incorrect wp_posts.post_name = 'asc' when I have custom post type called 'order'
This is my code :
print_r($args)
//Output
array(6) { ["post_type"] => string(9) "order"
["date_query"] => array(2) {
["before&...
0
votes
0
answers
244
views
How to store sensitive user data (passwords)
I want to create a plugin addon that allows my sites users to share private login information in a secure manner. So they'll enter these private details in a form on the frontend and I want to be able ...
0
votes
1
answer
914
views
Looping the data from WordPress database using foreach
I am trying to fetch data from the WordPress database table using wpdb and loop it using foreach statement so as to output results in select tag. I created a custom WordPress template and this was to ...
0
votes
0
answers
20
views
Job and Employee Performance Tracking with Product Safety
We are looking to connect a WordPress site to our database where an employee can scan an order barcode with an RFID scanner that was generated from our database and have the WordPress site query the ...
0
votes
0
answers
29
views
sort title descending with title with number
please help me,
i have title like this
'1-nen A-gumi no Monster Chapter 2'
'1-nen A-gumi no Monster Chapter 10'
'1-nen A-gumi no Monster Chapter 2'
'1-nen A-gumi no Monster Chapter 1'
'1-nen A-gumi no ...
0
votes
1
answer
491
views
Delete oldest wordpress post (SQL query)
I've reached the database limit on my hosting platform. I want to add a function to my functions.php that deletes the oldest post in my database anytime that I publish a new post.
function ...
0
votes
1
answer
394
views
What is the equivalent WP_Query of a SQL Query?
The problem
There is a post_author post type, the main post relates to post_author: every post has one post_author.
I need to have a list of all post authors to be sorted in a descending order by ...
0
votes
1
answer
99
views
Find locations of all featured images of draft posts via SQL
I'm trying to get the file locations of all featured images used in draft type posts via SQL and phpmyadmin.
posts type attachment should hold the location of the image in the guid column.
SELECT ...
0
votes
1
answer
493
views
Woocommerce - get daily sales meta
I am writing custom woocommerce plugin.
Does woocommerce has any daily sales report of each product?
I know, that get_post_meta can show total sales of certain product, but I need to show sales of ...
0
votes
0
answers
406
views
WordPress creating excessive joins on meta_query with search
I've a pre_get_posts filter with a check for main query and search, in this check I add a meta query:
$meta_query = array(
'relation' => 'OR',
array(
'key' => 'exclude',
'value' =&...
0
votes
0
answers
84
views
SQL database import #1046 error
As I am reuploading a WP website backup on a new host and importing the SQL database from phpMyAdmin, how do I solve this #1046 error ?
Error
SQL Request:
—
— Table structure for table ...
0
votes
1
answer
656
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
0
answers
3k
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
1
answer
23
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 ...
0
votes
1
answer
88
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
1
answer
125
views
A query to substitute images paths in gutenberg (website migration)?
I was used to do something like
update wp_posts set post_content = replace(post_content,'http://dev.example.com/website', 'http://www.website.com');
This seems not to work anymore for texts that ...
0
votes
0
answers
73
views
How To Toggle User_Meta in frontend in a form using PHP
I am trying to make a small form, that just has a submit button, and on submission, it should toggle user meta for the WordPress user. The button exists on frontend after content of post, and has a ...
0
votes
2
answers
83
views
Running a PHP SQL script on a wordpress page
This is a very basic question. I am using Serverpress for local development.I have been trying to create a dynamic dropdown.I did some reading and I found an example html,php and jquery script that ...
0
votes
0
answers
236
views
Query product's image path by category WooCommerce database?
I am writing a small query to grab image path and object ID from Woo_Commerce database. I am join taxonomy and relationship table to achieve this but somehow I am making mistake I can't realize. I ...
0
votes
0
answers
78
views
Get and Update Most Meta Value as an array in HTML form
I'm trying to update post meta for a meta edd_download_files the meta is in the form of an array. It is from a plugin so i can do it via admin, but still there is need to do it programmatically.
$...
0
votes
2
answers
1k
views
WPDB SQL query SELECT from category
I wrote SQL query to get items ID with 'instock' status, but don't know how to add to SELECT only from specified product category.
My code:
$results = $wpdb->get_col( "
SELECT p.ID
FROM {$...
0
votes
1
answer
388
views
How to speed up "My Account > Orders Page" on Site with More than 200,000 orders?
On my account>orders page, the slowest query is the following:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta
ON ( wp_posts.ID = wp_postmeta.post_id )
WHERE 1=1
AND ( ( ( ...
0
votes
0
answers
1k
views
how to retrieve specific product attribute value in an sql query?
I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attribute name" bottom line I am trying to query woocommerce products + all their ...
0
votes
1
answer
18
views
What steps do I need to take to install a local copy of a live website?
I need to create a local copy of a live site for development purposes.
The live site is 30GB+ in size and so I don't want to download all of the uploaded media.
I have copied all but the uploads ...
0
votes
0
answers
39
views
Safely changing UserID's, re-using deleted UserID's and automatically using deleted userID's instead of an increment
I'm looking for 3 different solutions all relating to user ids, I'm needing a solution to safely make changes without destroying the site.
Issue 1:
I am wanting to change the userID of a user from ...
0
votes
1
answer
515
views
SQL - Shorter way to query user and usermeta data
I'm looking to query a bunch of user and usermeta data into a single table. I'm able to do so by creating multiple temporary tables and a pivot:
create temporary table meta
select u.ID, u....
0
votes
0
answers
40
views
My website frequently redirect to a different advertisement URL
Can you guys help me to figure out why it's happening? Its mainly happen from my search engine result. From Google search when I click on my website it will redirect to a scam website.
Note: now its ...
0
votes
0
answers
18
views
SQL to Query the db and return all posts and it's metas
I am trying to query the wp db and return all posts and it's metas.
However, the return is very slow. Am I doing it the right way to get the most optimal results?
Please see my SQL below:
SELECT ...
0
votes
0
answers
388
views
Translating WP query into to SQL query
I have very complex wp query and I want to use sql query instead of this. Is there any way to translate wp query to sql query.
I am thinking that I will have a better control over sql query as the wp ...
0
votes
0
answers
1k
views
Wordpress search query, how to modify the sql
I have a problem with the query search, which means I would only look for posts with post_status = published. The problem is that after adding my conditions, wordpress writes an "OR wp_terms.name LIKE%...
0
votes
0
answers
644
views
Reset post IDs with all post meta
I imported posts from an old website.
Posts from the new website have IDs under 100.
Posts from the old website have IDs above 9934.
I tried to change manually the post IDs in phpmyadmin in order to ...
0
votes
2
answers
81
views
WordPress filter from custom table is not working properly
I want to filter the exact information from a custom WordPress table no matter the user has filled all the text boxes or not.
I have used a LIKE query but it`s not working properly if the user left ...
0
votes
2
answers
229
views
How do I loop/iterate through posts to edit all img tags?
Heads up, I'm pretty new to Wordpress... But I need to loop through multiple posts and change all 'data-src' attributes to 'src' so my images will display. What's the way/best way to go about doing ...
0
votes
1
answer
592
views
SQL query to delete users with multiple meta keys and comments
I need help putting together an SQL that can delete users if they don't have (metakey1 or metakey2) and (does not have comments)
I have this SQL which does it for single meta_key
SELECT *
FROM ...