Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

0
votes
1answer
18 views

How to copy user_nicename value into user_login

a hacker put value "admin" into all user_login fields. i need to copy user_nicename value into the user_login so users can login. is there a SQL command i can run to do this task in bulk, as their ...
0
votes
1answer
16 views

I can't figure out what's wrong with this statement. $wpdb->query update

I'm trying to use the $wpdb-query method, but can't seem to get it to work. I get a 500 error when I try the following: $update_status = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}...
0
votes
0answers
14 views

function to generate custom field for Mailster newsletter from WPgens referral code

I’m quite new to WordPress – and coding in general except I did a lot of SQL, R Matlab etc during my studies a long time ago so I can learn if I know where to search :-). But php, javascript etc are ...
0
votes
0answers
15 views

get_users() and custom meta_query with SQL procedure

I'm writing a WordPress plugin with a users listing. To build this users listing, I use the get_users() WordPress function which work perfectly. I built a form to select some options to find users ...
0
votes
0answers
10 views

How to query SQL for coords nearest a point? [migrated]

This is what i am trying to do: From a form I GET the coordinates: &usp-custom-20=45.492384716155605&usp-custom-19=9.206341950000024 The I query SQl to find all posts near those coordinates,...
0
votes
0answers
22 views

Show posts with a specific category or aithor

Im creating a custom feed for users on my website, where each one can follow users and categories and see post from them. I'm not really sure how though. I have tried to use author__in and ...
0
votes
0answers
16 views

Display posts with datas of custom database table

I think the title is not very explicit, but I don't know how to name it ! Well, I'm totally stuck on a question: To make it simple, I work on a site referencing places and their information. These ...
0
votes
0answers
14 views

Searchform for custom table

I have a custom SQL Table in my database with a list of places and their information. I would like to create a searchform to search this table for places and that the results are displayed in a ...
0
votes
1answer
13 views

Nested select statements not working

I have 2 tables I need to search. 1st table Name: Personnel Fields: id, lname, fname, department, extension 2nd table Name: department Fields: id, department The 2nd table has the full department ...
0
votes
1answer
51 views

Delete posts with word count less than x number of words

I searched a lot about this, found plugins that are out dated and consumes massive resources and finally do nothing, is there like an SQL line to delete all posts that have a word count like less than ...
0
votes
0answers
8 views

sql query for selecting btween two amounts

I am trying to achieve result by selecting dropdown between two amount range. echo '<option value="browse-events?city='.$browse_city.'&type='.$browse_type.'&price=Free">Free</option&...
2
votes
1answer
56 views

Updating WooCommerce variable product stock issue

Soo.. I've created CRON script, that each 1 minute retrieves an actual stock systems data, converts it for Wordpress/Woocommerce database table and updates stock. On database side everything looks ...
0
votes
2answers
39 views

Fastest way to display 5000 post titles?

I want to display all CPT titles on its archive. I don't want to use pagination. All must be in 1 page. There are 5000 posts. Echoing the_title on the archive loop works but it's slow. What's the ...
0
votes
0answers
17 views

Display data from 'comments_clauses' in comment object

I want to add display name from users table to the comment object in WP, but failed. I don't know where is the error in my code below. This is my code. add_filter( 'comments_clauses', '...
0
votes
1answer
20 views

Alter the cost of products using phpmyadmin sql query

What is the SQL query can i use in phpmyadmin to alter(update) the listed products cost in woocommerce. EX: I want to add or subtract $100 from all the listed products.
0
votes
1answer
19 views

How to Add or Change Post Title

How to add post titles with new titles via sql? example post title now "beddu". i want to adding/ change "Add beddu" thank before
0
votes
0answers
36 views

CPT with custom table? Create posts automatically?

Variations of this have been asked in the past, for example: HowTo: Custom Post Type (Meta) to Custom Table , but I am wondering if there is a better answer for my case. I have an SQL table with 30 ...
0
votes
1answer
17 views

Show Mysql table elements as pages in Wordpress

I am trying to build a WordPress site, but I need a specific functionality and I haven't been able to find a plugin for it. I'm going to be scraping sites info and posting the info into a DB (this is ...
0
votes
1answer
27 views

Slow Query On Search

Please I have a very slow query on my wordpress search, checking the processes it takes upto 40sec to execute using SHOW FULL PROCESSLIST; below is a sample of query SELECT SQL_CALC_FOUND_ROWS ...
0
votes
1answer
15 views

insert post fails after multiple postings

I have a script that automatically makes posts and uses insert_post() to do so. Running the script works but after a few loops (running insert_post()) the script just ends without any warnings or ...
0
votes
1answer
24 views

How to transfer categories (default) to custom taxonomy?

I wanted to move all my posts from the default post type into the new custom post type i've made. I was able to do it using this code: UPDATE wp_posts SET post_type = 'movies' WHERE post_type = 'post'...
0
votes
1answer
28 views

Delete/Replace words from X to Y in post content

I am looking for a way to search and replace some words in my database. I have many posts on one of my blog and i want to replace words using regexes. before publishing, I marked every place I wish ...
0
votes
0answers
47 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__, '...
2
votes
1answer
62 views

Advanced WP Query hogs the SQL server

I recently developed a website for a customer who is a estate agent. Included in the project is a post type called listing. This post type is used for all of their listings and additional information ...
-1
votes
1answer
23 views

Get all the related data from WordPress DB

I have 2 custom tables inside the DB WordPress is installed in, With one-to-many relation between both tables. Here are the two tables: posts table ...
0
votes
0answers
21 views

Why does DROP TABLE-ing the `wp_options` reset my user session?

If I do: global $wpdb; $wpdb->query("DELETE FROM wp_options"); Suddenly, I'm logged out. But how come? I thought all sessions are kept locally, surely, a reference to my session must be present ...
0
votes
1answer
30 views

PHP -> SQL Query with Summing

So I'm trying to display the sum of Paid Transactions for a customer's account: SELECT SUM(`payment_amount`) FROM `wp_gf_entry` WHERE `created_by` = '2' AND `form_id` = '37' AND `payment_status` =...
2
votes
2answers
112 views

How to make WordPress plugin check for database changes and then do something?

How do I for instance check if there is written a new comment in the database and then make my plugin register that there have been a change? I will use this information to do something in the ...
0
votes
1answer
30 views

Filtering posts for unique titles, only the most recent

I am trying to understand how I can fetch posts for an archive that: Have a unique title Are the most recent version of said unique title So, if I have 3 posts: title: 'ID1: My Title' date: 01/01/...
0
votes
0answers
25 views

Is there a way for two deferent themes to consume two different DB on a same WP instance?

Before you downvote, yes I know there is a lot of similar questions around the web. But nothing touches my specific situation and how I should approach this problem. I have a build a new theme for a ...
2
votes
1answer
56 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
0answers
36 views

Connection between user_roles in database and show user data in the front-end

I'm working in WordPress and I'm trying a student/examiner service, with each role have specific task and rights in the site. This is my requirements that I want to implement (so far): I have 3 user ...
1
vote
0answers
43 views

Wordpress database error: You have an error in your SQL syntax

I am receiving the following error when I try to so a search in my media folder and I don't know how to correct it: WordPress database error: [You have an error in your SQL syntax; check the manual ...
1
vote
1answer
23 views

sql select query in wordpress 'page' [closed]

I want to run simple sql select query in wordpress 'page' without using php. I want to display a single row of database.
0
votes
1answer
236 views

Query WordPress Database and Post HTML Table

I'm looking for some help building the base code to query my WP database, retrieve a table and then post this on a page. There seems to be a lot on the web to assist with this, however with limited ...
5
votes
3answers
237 views

register_post_status - show_in_admin_all_list & show_in_admin_status_list does not affect query

In the register_post_status, I've already disabled show_in_admin_all_list & show_in_admin_status_list for my custom status my_hidden_status However, from the query log the post_status ...
0
votes
1answer
31 views

Lost in trying to create user database system

I've done a lot of reading and am still lost in how to approach my website. My goal is to have a login system, where these users have their own content they can save and manipulate. Say for example a ...
0
votes
0answers
17 views

Searching through database table and posting results

So, I have looked at this link here Creating a search form for custom fields and I think this is pointing me in the right direction. However, I am wondering how I would pull them from a database that ...
0
votes
1answer
24 views

How can I prevent certain custom roles from seeing other custom roles on the user list page?

So I am building a system with 3 different custom roles - Admins, Providers, and Users. Providers have access to users.php, or the list users page. However, they should not be able to see/edit/access ...
0
votes
0answers
18 views

Change media author to post author

I have many users images that I uploaded. I need the author of these images to be changed to the author id as I have restricted each user to view only their own media, and of course the images for ...
0
votes
1answer
147 views

SQL query to set posts in bulk based on the post content

I have thousands of offline links in my posts, and I'd like to set them all to draft. I know the links are in the format example.com/fileX. So I needed a SQL query to search the post content and ...
0
votes
0answers
19 views

Update data from live server data base to dev server data base

Before migrating a new site from its development server to a live server, I need to copy the most updated data in live database to dev datbase (i.e users, bookings, posts...) I've checked several ...
0
votes
0answers
16 views

How to get the Custom Taxonomy link for specific post in a SQL query

I'm using the 'wpDataTables' plugin and there's a lot of working with SQL which I haven't done before. I'm sorting custom taxonomy data from posts into a table and need each bit of data to link to ...
0
votes
1answer
24 views

How to set posts to draft in bulk based on the content of the post

I have thousands of offline links in my posts, and I'd like to set them all to draft. I know the links are in the format example.com/fileX. So I needed a SQL query to search the post content and ...
0
votes
1answer
64 views

How do I display SQL query on a specific page of my wordpress site

this is the query i want to display SELECT account_number, consumer_name, bill_amount, due_date, disco_date, bill_status FROM wp_bill_inquiry WHERE account_number = input AND pin_number = input by ...
2
votes
1answer
40 views

Using table lock with wp_insert_post?

I'm running a cron every 5:th minute that inserts a lot of posts. Sometimes it happens that those crons are running both at the same time. To be sure that not causing duplicate posts. I would like to ...
0
votes
1answer
99 views

How to create index (sql) to a meta_key?

I am new in programming, and the sql is absolutely stranger for me. I create today a new meta_key on my multisite, but when I use this in a query, my site will be horrible slow... I read (here: https:/...
0
votes
2answers
54 views

Bulk update set of URLs via SQL

I've checked multiple questions and can't seem to find the answer. How can I update a list of URLs to either include "-google" at the end of the permalink, or set the URL to a custom url. My list of ...
1
vote
0answers
34 views

The function can not create a table on MariaDB server

The function works on MySQL server well but it can not create a table on the MariaDB server. What could be the problem? public function create_table() { $current_version = get_option('...
0
votes
1answer
33 views

Pull MySQL data from multiple tables and merge into 1 PHP array

Appreciate help in advance. I am dealing with a bit of a pickle with a formula. I am trying to create a page template that will display a list of users, specific metadata from usermeta table + ...