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
1answer
830 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 ...
4
votes
2answers
630 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
1answer
786 views

SQL Query Search page

I am trying to create a Wordpress webpage that has an input text box and a button. what I want to do is take the input text from the text box and use it as a parameter to search a table I put into the ...
1
vote
2answers
31 views

Syntax for $wpdb->prepare when searching in two columns

I have this working statement for searching a single column in my database: $foods = $wpdb->get_results( $wpdb->prepare( "SELECT id, foodname, namevariations, calories, carbs, fat, protein, ...
0
votes
1answer
56 views

SQL to set Display Name to First Name + Last Name

I'm trying to set the wp_users.display_name for a rather larger users db using SQL query. Got till this point: SELECT x.display_name, x.first_name, x.last_name FROM (SELECT u.display_name, f....
0
votes
0answers
6 views

How to query results for post_title and Custom Post Type/ACF field pivot query

I have a custom query that needs to match a search term to a custom post type of event by post title and by an ACF field host and then filters out events that have passed the current date to a REST ...
6
votes
3answers
11k views

Add custom fields to search

I want to add a custom fields ("introduction" and "ensavoirplus") to search of Wordpress, but the SQL code is not exact. I don't understand if i do a mistake or if WP don't can do this. But my attempt ...
0
votes
1answer
13 views

I want to get on those users their meta value are like “AGENT” .. but this query is not working

SELECT display_name FROM $wpdb->users WHERE id IN (SELECT user_id from $wpdb->usermeta where meta_value LIKE '%agent%')
0
votes
0answers
12 views

Taxonomy list inside the query

Is it possible to get a list of the "terms of taxonomy" or "just used taxonomy types" defined within that archive without looking at all pages of an archive query in a loop? What I ...
1
vote
1answer
706 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
1answer
753 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
1k 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'...
8
votes
2answers
43k views

How to use $wpdb to delete in a custom table

I am having trouble finding a good resource on using the $wpdb function. I am trying to delete a row from a custom table named: eLearning_progress $removefromdb = $wpdb->query("DELETE FROM ...
0
votes
0answers
16 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 ...
1
vote
0answers
15 views

Editing the default wordpress search

My wordpress sites search function is not relaxed enough for my liking. I want it to match more items and be less strict. How would i do this? I was thinking it would to do a pre-get posts filter but ...
0
votes
1answer
695 views

how to insert missing tags into the posts through mySQL?

I am looking for a SQL query to insert a tag to multiple posts from a specific category. A pseudo query looks something like this: INSERT INTO POSTS VALUES TAG = "tagName" where Posts in_category("...
0
votes
1answer
709 views

Posts modified in the last 48 hours

I am using the code below to generate posts created in the last 48 hours. function filter_where($where = '') { $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'"; ...
0
votes
1answer
45 views

wpdb->get_row is selecting the variable as a column name

I'm using wpdb to get a row of a table $file = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}vip_files WHERE {$file_hash} = `hashcode`&...
0
votes
1answer
18 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 ...
1
vote
2answers
25 views

Difficulty importing my live site to local

Im using local by flywheel, Here are the steps i have taken so far: Installed local by flywheel and created a site called stage Downloaded the website from CPanel and also the SQL database Imported ...
0
votes
1answer
578 views

Deactivation Hook does not remove database

If I deactivate the plugin, the database table does not get removed. It is removed only when i delete the plugin. Here's my code: <?php register_deactivation_hook( __FILE__, '...
0
votes
1answer
686 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 ...
0
votes
2answers
21 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
0answers
22 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
1answer
24 views

SQL Bulk update all Wordpress user's nicknames to firstname + lastname format

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead. I've put together this code ...
0
votes
1answer
26 views

How to get database connection details without longing to cpanel in WordPress?

I am creating a WordPress plugin and in my plugin i need to do some SQL statements ,in the site i am working on i have access to WP-admin but i cant get to the files to get database name and password ...
0
votes
0answers
28 views

Sql query to get all metadata for a post

I have three tables in my database one is users table the other is posts and wp_post meta. In the user table I have all the user details . In the wp_posts table I have different posts types . I want ...
0
votes
2answers
2k 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
1answer
823 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->...
0
votes
2answers
16 views

Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?

With a default Wordpress install, with no plugin installed, does the read-only visiting of the website generates write operations in the database? By read-only, I mean: visitors come and don't post ...
0
votes
1answer
6k 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
0answers
23 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 ...
1
vote
1answer
37 views

Problem with creating tables for Plugin

I hope someone can help me. I try to execute this code to install the tables for my Plugin. But for some reason it doesn't work (Doesn't appear in my wordpress database) and I can't find out why. Can ...
6
votes
1answer
4k views

Creating 20,000 Posts or Pages using a .csv file?

Here's my challenge: I have a .csv file which contains 20,000 rows of data. Each row contains 5 columns of data on an particular individual. I need each row (each person) to be populated into a ...
2
votes
1answer
57 views

how to execute different sql query in non-sanitized $wpdb->get_results function

I saw $wpdb->get_results that function is not sanitized by core code($wpdb is get_results escaped). For example, in following code $wpdb->get_results( "DELETE FROM `wp_postmeta` WHERE `...
1
vote
1answer
581 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
44 views

Using AND and bracket grouping in SQL not working

I am trying to combine two conditions in a query but it isn't working. but running the conditions independently works. LEt me explain. When I run this query: SELECT DISTINCT SQL_CALC_FOUND_ROWS ...
1
vote
1answer
36 views

Wordpress SQL Injections through User Agent

Currently Wordpress seems to be scoring bad on SQL Injection through User Agent. The testing tools that are being used return that it's insecure because it returns HTTP responses (errors) when you ...
1
vote
0answers
12 views

Needing to move content from postmeta to posts in sql [closed]

I have conent located in a custom field named main_content in wp_postmeta and need to copy that content to post_content in wp_posts. There are about 400 posts and have no sql background but should be ...
0
votes
2answers
892 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
29 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 ...
1
vote
2answers
2k views

get all posts in custom post type by ACF field value

I have a custom post type with custom fields(advanced custom fields plugin). one of the custom fields named program_id. i can`t understand how to get all of the posts in that CPT where the ACF field ...
0
votes
1answer
30 views

Use $wpdb or other PHP script method to find/replace in WP database

I'm hoping to push a bug fix for a custom WordPress plugin my sites use. The plugin registers a shortcode with various attributes. However, there's a bug where one of the attributes is incorrectly ...
0
votes
2answers
563 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 ...
0
votes
1answer
2k 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 ...
1
vote
1answer
29 views

WP_POSTMETA changes site crash

I try to update wp_postmeta from SQL script. This is my original row in table: a:7:{s:16:"lambda_page_item";a:24:{i:0;a:9:{s:9:"grid_size";s:3:"940";s:7:"boxname&...
1
vote
1answer
842 views

Get posts by category with pure SQL query

I have a meeting post type, whose titles automatically get set to a date of the form m/d/Y. I have the below query which gets all unique years from the post titles by selecting distinct values after ...
3
votes
1answer
591 views

Deleting All tags except categories Wp database

Please Is there any way to run an SQL code to delete all post tags in wordpress except categories via database. I want to run an sql code that will delete all my tags in wp, but not deleting my post ...
0
votes
1answer
3k 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
2answers
583 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....

1
2 3 4 5
15