MySQL is an open-source, relational database management system.

learn more… | top users | synonyms

0
votes
1answer
23 views

MySQL swap one table for another?

So I have a situation with this WordPress site I'm doing where I have to swap the positions of my featured images. I have two per post thanks to the Multiple Post Thumbnails plugin, but now whatever ...
0
votes
0answers
8 views

Mysql join 2 columns into 1

Hello i could really use a hand here.. the thing is i want to make 2 tables for a project - 1: Shifts: - which has: id, usr_id, date, start_time, end_time, and pending - 2: shifts_extra: - which ...
0
votes
1answer
26 views

How to set up an auto delete post?

I want to create a form in which when a front-end sets a date and on that date the post gets automatically deleted. Is it possible?
0
votes
0answers
8 views

MYSQL ignore categories on Wordpress widget

I have this WP widget that pulls random products from the DB. What I really want is to be able to include just a few products categories (or exclude). Can anyone help me? I appreciate. <?php ...
0
votes
0answers
44 views

#1115 - Unknown character set: 'utf8mb4'

When I Import Mysql from local server to web ser it is showng me error 1115 - Unknown character set: 'utf8mb4' in Creating wordpress wp_comment table CREATE TABLE IF NOT EXISTS `wp_commentmeta` ( ...
-1
votes
0answers
11 views

Replace existing pages with new pages, keep menu links

I've searched for this and found similar, but not the same issues. I basically want the same functionality as 'Enable Media Replace' but for replacing pages and posts. I'm redesigning an existing WP ...
0
votes
3answers
67 views

Order By Multiple Meta Fields

I have two custom fields: meta_key1 is boolean (0 or 1). meta_key2 is a date value - 20150623 for example. Not all meta_key2 fields have an explicit value. It looks like their being treated as an ...
0
votes
1answer
41 views

Updating with $qpdb->query() always returns 0 rows affected

I'm experiencing an odd situation while running an UPDATE with $wpdb->query(). Given the users table, with columns user_id (Primary Key) and status, and the user 3 existing and with status 0, I ...
-1
votes
0answers
17 views

Ordering by multiple custom meta data fields

I'm trying to sort WooCommerce product results by several meta data fields, currently this works for one, "Routine". The fields have been created using Advanced Custom Fields. The final result should ...
0
votes
0answers
6 views

Delete all wordpress posts from db that matches a certain condition

Am trying to delete all posts from wordpress database, that are X days old and have a particular meta key-value attached to it. So simply something like this(pseudo sql): DELETE FROM `wp_posts` ...
0
votes
1answer
10 views

$wpdb returns duplicate posts

I have created a shortcode which shows the posts which were created after the user last logged in. The shortcode is working perfectly fine, but I am not sure why but I am getting 7 duplicate posts. So ...
0
votes
2answers
35 views

Saving custom term value to the database in new table

So I'm trying to save the value of a custom term to my database. The table is created as is the custom term. The code below outputs the text field onto my custom terms page but it just doesn't save ...
0
votes
0answers
14 views

Google-App-Engine[PHP]: Error trying to establish database connection

Hi to whom this may interest, I am finding a problem with the cloudsql as database connection is not being established. I have followed the following site step-by-step ...
0
votes
0answers
20 views

How to fix pagination issue on wordpress

I have a category with 2 subcategories. i have created a custom category template, to show the posts from the subcategories of that category, so it look like that: category page shows: Subcategory ...
0
votes
1answer
20 views

How to fetch all meta_key and meta_value using post_id wihout duplication of post meta using sql query

How to fetch all meta_key and meta_value using post_id wihout duplication of post meta using sql query. This query is repeting the post meta each time . $sql="SELECT * FROM wp_posts LEFT JOIN ...
0
votes
0answers
10 views

get_metadata() vs get_post_meta() vs custom query [duplicate]

I have 27 items of post_meta data that I need to get out in a class that I use through-out my website. Currently I'm using: $this->postMetaData = get_metadata("post", $postID); This returns an ...
0
votes
1answer
46 views

WordPress get pagination on wpdb get_results

How do I gee the numbered pagination of custom wpdb result? below code will show one latest post from each authors in the site. I want to show 20 posts per page with a numbered pagination. $postids ...
0
votes
1answer
17 views

worpress update post meta data(custom field) by post link

I have a post in my wordpress website, which has lot of custom fields. I have an excel sheet with "post link" - "custom field data" combination. That custom field(video url) is already set for each ...
0
votes
2answers
56 views

Show only one post for each author ( Page loads too slow )

I want to show only one latest post by each author and found this code that it working. However, it takes too long to load the page since I have over 100K authors and 100K posts in database. How can I ...
0
votes
1answer
22 views

Foreach only outputs if id is 0

I'm developing a plugin. On the activation hook i do this: /* Create category */ global $wpdb; $rpdb_category = $wpdb->prefix . "rp_category"; if($wpdb->get_var("show tables like ...
3
votes
1answer
68 views

Query both first_name and last_name from wp_usermeta at the same time

I'm trying to fetch both the first_name and last_name of all users at the same time, using the wpdb-object and the wp_usermeta table. I can't seem to figure out how to get both in the same query. ...
0
votes
2answers
62 views

Your PHP installation appears to be missing the MySQL extension which is required by WordPress

After I upload my website on server, I got that message .. I searched on Internet and I found on Wordpress community this link , I followed the installation steps, the error message gone, but I got ...
0
votes
1answer
31 views

Files on Localhost, Database on Server

With Wordpress, is it possible to work on localhost but have the DB on a server? So that workflow will be: 1) Work on localhost (but connected to remote database) 2) Upload JUST files via ...
5
votes
2answers
121 views

Optimize Wordpress Query that take 5 seconds to execute

I have a large wordpress database: rows in key tables: 730K wp_posts 404K wp_terms 752K wp_term_relationships 27K wp_term_taxonomy 1.8 Million wp_postmeta The issue is that I have a query ...
0
votes
0answers
44 views

Count posts of child category in parent category

Hallo Wordpress Comunity, I need your help. I have a Woocommerce shop site with multiple authors. In the sidebar I want to display a list of woocommerce product categories by author (based on posts ...
0
votes
1answer
33 views

How to remove 'GROUP BY' from SQL query produced from get_posts?

Wordpress, Archive Cateory page. From default WP_Query->get_posts() we are getting something like this: SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = ...
0
votes
0answers
24 views

wpdb giving different results then query in SQL Editor

I'm trying to read candidates and the relation with expertises from 2 custom tables in my WP Database. This is my WPDB query : $candidates = $wpdb->get_results(" SELECT * FROM ...
0
votes
1answer
40 views

Wordpress page and plugin list using sql query

I want to get all published pages and activated plugins of my word press site,i want all pages and plugin using mysql query.i don't want to copy paste all pages from wp admin.i want to get this list ...
0
votes
0answers
11 views

Can tables in WordPress Multisite be combined?

I inherited medium size wordpress multi installation. At the time there were only about 20 different sites, each with their own set of database tables. We now have about 120 sites and over 3,200 ...
0
votes
0answers
37 views

MySql query to retrieve post_title, post_content and feature image link BASED ON A CATEGORY

I have been trying for quite a long time to retrieve post_title, post_content and feature image link for all posts BASED ON A particular CATEGORY, from a wordpress database. I have got a query: ...
1
vote
2answers
29 views

How do i fix? WordPress database error: You have an error in your SQL syntax;

I am Using Wordpress for making a website and getting below Error only on my pages and No shortcodes are working due to this error. This error ONLY seen on PAGES they are working fine on POSTS. I ...
0
votes
1answer
34 views

Alternative functions for mysql_free_result and mysql_ping in wordpress functions

what are the alternative function for mysql_free_result and mysql_ping in WordPress functions , does WordPress function provides all the functions like php ? is it necessary to Free result memory for ...
1
vote
0answers
35 views

mysql_real_escape_string() vs. esc_sql() in WordPress

Does mysql_real_escape_string() and esc_sql() in WordPress both do the same thing? I tried the following: $fetch_row='<p>And again for single posts</p>' echo mysql_real_escape_string( ...
0
votes
1answer
39 views

$wpdb->prepare is not working like mysql_real_escape_string

I'm working on a WordPress plugin and recently I have planned to migrate from SQL to $wpdb. I'm using a method called $wpdb->prepare instead of mysql_real_escape_string but it does not work. Here ...
0
votes
0answers
78 views

Loop through multidimensional array for values, then interest into mySQL table

I have a package of JSON that gives me something like this: [{"a":"5", "b":"9", "c":"3"}] I have a table with with three columns: a, b, c. I want to create entries into the table to match 'a', 'b', ...
0
votes
0answers
34 views

Term and sub term from custom post type query

I have created a custom post type and taxonomy for a goods catalogue for a hire website. This works fine. I am trying to generate a report that lists all items and their category and sub category. I ...
0
votes
1answer
44 views

“Error 1064” when importing msql database after updating wordpress version to 4.2.1

I have a error in importing my sql file that contains the db of my site When i export from local, is ok my settings Server: mysql wampserver (127.0.0.1 via TCP/IP) Server type: MySQL Server version: ...
1
vote
1answer
31 views

Safe to delete blank postmeta?

We have a lot of rogue custom fields. I feel that we can clear significant space in the DB if we remove the blank values. If I query my database with the following: select * from wp_postmeta where ...
0
votes
0answers
51 views

Wordpress 4.2.1 upgrade mysqld spikes in cpu usage

After upgrading to WP 4.2.1 we have encountered some huge problems with site being unresponsive. We have located this as the problem (we think) # Query_time: 13.341332 Lock_time: 0.000054 ...
1
vote
0answers
69 views

How to use update and delete query in wordpress

First i write manually update, delete, insert and select query and execute data with mysql_query function Like this: Select query $prefix = $wpdb->prefix; $postSql = "SELECT DISTINCT post_id ...
0
votes
1answer
91 views

WordPress and SQL - Update and Insert from another table if column value doesn't exist

Stuck with some mysql for my wordpress site. All within 1 DB. I am attempting to update wp_options table from wp_2_options (Multisite). They both have option_name (unique_key) and option_value ...
0
votes
1answer
58 views

Wordpress with php5-fpm and nginx

I am trying to complete an install of wordpress using php5-fpm and nginx, with a database on a remote server. However, wordpress doesn't recognize the existence of mysql to allow me to connect to the ...
0
votes
1answer
44 views

live site do not update after importing sql database

My live website is not updating after importing sql database from wamp local server until last time all went perfect but last night I was not able to see the changes live made in local. what I did: ...
0
votes
0answers
20 views

More efficient remove meta data from posts?

Looking for a better way to do this, bulk remove custom field from all pages with a taxonomy -> people -> term of names. Any thoughts ? This is attached to a single button on a custom admin panel not ...
0
votes
0answers
70 views

Ajax is running my insert query twice

I am working in WordPress and I run a function to insert a row in database with ajax. Ajax runs but for some reason insert operation is performed twice. Below is my code Ajax jQuery(function ($) { ...
0
votes
1answer
60 views

Add value to array in database

I have a custom database in my WordPress site where I want to save multiple values to one row. Let's say I have an entry: id: auto increment pageid: id of current page time: text (is an array ...
1
vote
1answer
19 views

Are database queries created using WordPress filters protected from SQL injection?

I'm using the WordPress 'posts_where' filter (https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where) to alter my queries as below: function filter_my_search($where=''){ ...
0
votes
1answer
35 views

Stop my loop to register data twice

I am facing a problem here. The code below is running on my site and when i fill in the form and check my database the data has been registered twice. Please the the following php code from my ...
0
votes
1answer
34 views

Function returning queried meta value based on current post ID

I have written several queries which sums download counts grouped by the post they are associated with, and other relations. They work great for exporting to CSV and other uses outside of WordPress, ...
0
votes
2answers
81 views

Wordpress SQL injection

How to make below code safe from sql injection ... I am working in wordpress. global $wpdb; if($wpdb->insert( 'votes', array( 'votes' => ...