SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).

learn more… | top users | synonyms (1)

0
votes
0answers
5 views

Delete duplicate media in SQL only

I have uninstalled WPML and deleted all WPML tables in the DB. Now, I have duplicate media (one per old languages) in my SQL only (not in the FTP). I would like to delete these duplicates and only ...
0
votes
2answers
37 views

Database SQL Error, Should Work

I'm trying to get my posts to order by radius, and so far i'm struggling, I've been using the following tut by Steve MArks, http://biostall.com/performing-a-radial-search-with-wp_query-in-wordpress ...
0
votes
1answer
37 views

Database Query not working

I've been following a tutorial by Steve Marks which goes throught adding information from posts to a new Database Table as well as the usual postmeta one. However no matter what I try, It will not ...
0
votes
0answers
23 views

How to display 20 posts by categories in custom sorted order and by post tile

I need to display 20 posts by categories that have custom sort order and orderby post title. Category (VW) order 1 - Beetle - Golf - Jetta - Toureg Category (Honda) Order 2 - Civic - Odyssey - Pilot ...
0
votes
0answers
21 views

Nothing wrong with SQL but still getting an error

I'm developing a plugin and I need to perform a SQL query with GET parameter. The code looks like this: if (!empty($_GET['editDoc'])) { global $wpdb; $id = $_GET['editDoc']; $table_name ...
0
votes
1answer
24 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 ...
0
votes
0answers
18 views

External SQL Database (Login Details) to update wp_users with new users

I have an external database which currently has a Username and Password field, which are plain text (password field not using any hashing). Is it possible for when I update this database that it will ...
0
votes
1answer
27 views

Conditional statement within WP SQL query

I have a form on a Wordpress page posting data to a table called 'members'. I have a second page displaying this data in a table. All is working well. The data is being displayed using: $myrows = ...
0
votes
1answer
45 views

WP User Query get all authors with last name starting with specific letter

I need to program a page to which I pass an initial through the url and it will show all author users whose last name starts with that letter. I would like to do this via WP User Query so that I can ...
0
votes
2answers
24 views

This wp_query will not return any posts and only seems to work with post_status inherit?

I'm having difficulty returning a list of posts. This file is contained in a plugin folder (ultimately I want to have a cron job just run the script here to delete posts with invalid urls in the given ...
1
vote
2answers
47 views

Getting users who registered 360 days from current date

As per the title, what I want to do is run a custom query that (using WP-Cron) will run once a day to check for users who registered exactly 360 days before the current date (don't need time, just ...
0
votes
0answers
20 views

pre_get_posts with custom SQL

I have a scenario where there is a custom form on an archive page. I want to use pre_get_posts to modify what is displayed on the archive page, and show the paginated results. The issue is I first ...
0
votes
0answers
22 views

Insert the same row 3 times

I am trying to developing a plugin for body mass index. I am trying to enter a row while creating table in register_activation_hook. When activation is finished i see 3 same rows in database. Here is ...
0
votes
0answers
17 views

How do I update post based on meta_key in another table?

So I have a function that is called by the wp_schedule_event (cron job) once daily. The goal of the function is to set all posts with a field wpcf-engine-days-to-go that has a value of "0" to a draft. ...
0
votes
1answer
16 views

Sql query returns empty. But not

my sql query returns empty $sql = $wpdb->get_results('SELECT * from table1 WHERE id = ' .$bransId); And im sure that $bransId is not empty. ( i checked)
0
votes
0answers
14 views

Adding left join to sql query

im trying to get some extra data from another table with left join (or may be another join, because one data from one table ). But i couldn't success. Because my query is little bit different for me, ...
0
votes
1answer
74 views

Convert a WP Query into a simpler SQL query to fetch only COUNT of posts

I have this WP Query running for each row in my admin screen for a certain post type: $entry_args = array( 'meta_key' => 'wp_comp_entry_competition-id', ...
0
votes
1answer
30 views

Inner Join user tables to select users with roles

I am trying to view a list of users (who are music artists) with the following function. function show_authors($ltr) { global $wpdb; $querystr = "SELECT $wpdb->users.* FROM ...
0
votes
0answers
12 views

Get adjacent post data, ordering by custom field values (by Wp-query?)

I want to build a custom version of the adjacent-function of wordpress post. I have two custom field values for each post, my layout is the following: metafield1 value 1 & metafield2 value 1 | ...
0
votes
1answer
17 views

DB_HOST - is LOCALHOST speedy than domain name? [closed]

I am interested, on some hosting(although they are paid hostings, and even the domain.com DNS nameservers are pointed to that hosting), you have to insert: mysql.domain.com (instead of: localhost) , ...
0
votes
1answer
95 views

SQL Error wp_commentmeta - incorrect table definition

I'm trying to import a database and wonder how I can stop getting the following error? "#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key " ...
0
votes
0answers
18 views

Problems with database query where two metavalue-key pairs meet condition

I've been trying to put together a database query where the different meta_values of two different meta_keys match the query. One example would be: delivery_date is '2015/06/11' AND supplier is ...
0
votes
1answer
67 views

Sort users by “birthday” using WP_User_Query

I have created user meta that holds user birthday (birthday). birthday is date field. Now i am trying to figure how to sort (get) all users that have birthday based on specific month. I have ...
0
votes
1answer
34 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
1answer
20 views

wpdb->get_var always returning 0

I am trying to run this statement: global $wpdb; $amt = $wpdb->get_var($wpdb->prepare("SELECT SUM(amount) as amt FROM wp_pay_table WHERE postid = %i", $pid)); ...but $amt always comes out as ...
0
votes
0answers
14 views

Show different content in the same URL

I have a blog powered by Wordpress. I need to show different contents in a same webpage according to the date. Say I have few posts with the url format: domain.com/post-01022015, ...
1
vote
1answer
47 views

Auto-update tables from database

On my WordPress homepage I would like to have a table that can auto-update based on database changes at a given time period. I am trying to find the best solution to this problem, weather I code it ...
6
votes
2answers
109 views

Whats the difference between post_limits and pre_get_posts?

Because of the lack of documentation about post_limits, its hard to learn more about this function and when to use it. Never used it before or seen it used so maybe its not to be used? function ...
0
votes
0answers
64 views

phpmyadmin sql error when importing database

i get this error when i try to import my wordpress database from wampserver "localhost" to my live site on the internet. MySQL said: Documentation 1064 - You have an error in your SQL syntax; check ...
0
votes
1answer
27 views

Export Posts with specific custom fields by sql

My development site has posts with custom fields. Meanwhile my live site has more posts added while I'm working on my development site. Now I want to export posts with specific custom fields from live ...
5
votes
2answers
166 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
42 views

Function is creating too many queries

I have code that displays a list of categories and orders them by the number of ACTIVE posts in the category. This is determined by comparing the custom field of due date against the current date. If ...
0
votes
0answers
28 views

How to optimize get post query

I have a dynamic Wordpress site with large number of posts (almost 2 millions), and need to optimize custom archive search query. This is what I'm using now and it takes ~0,5s (standard query_posts() ...
0
votes
1answer
31 views

Why my query does not run with prepare

Hi Below is my query and it works with prepare keyword on the localhost but whenever I use prepare keyword with my queries on live server the data does not show up and as soon I remove prepare from ...
0
votes
1answer
51 views

How to filter sql only for a specific post type

I have been trying to join a custom table with a regular wordpress query, but only under a specific condition (a specific post type). I have a single-event.php template that runs the main query, and ...
0
votes
0answers
48 views

Change permalink , keeping old structure with date

Currently on our website we have the /date/postname permalink structure with quite a number of posts. For SEO purposes we want to change it to /postname permalink structure but we want to keep the ...
0
votes
0answers
14 views

How to Use WordPress SQL Database on Sub-domains or Directory

I have a domain website.com in English and want to translate a directory to Spanish website.com/es taking exact content from website.com Question: How can I use same database on this directory?
0
votes
1answer
17 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 = ...
0
votes
2answers
260 views

How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?

I have a custom post type named store and I have a custom taxonomy city, I also have a meta box with a field that is stored with update_post_meta( $post_id, 'store_postal_code', $postal_code ); it ...
0
votes
1answer
1k views

Add special meta box to custom post type

I have managed to add a meta box to my custom post type (see code below) Now I need to add another meta box. With this box I want to display / edit a value from another table called ...
0
votes
1answer
35 views

Clean up very big and very dirty database

I'm trying to clean up a database in order to move a website from a server to another. Database is more than 1gb, mostly posts revisions and spam comments. Is it safe for instance to do something ...
0
votes
1answer
62 views

Wordpress Custom Search By Alphabet and order by asc and sesc

I am new to word-press but i can easily work on core php and other mvc framework,acutally i want to add custom search for only subcategory post. The search will with below Search post By old to new ...
0
votes
0answers
81 views

How can I avoid duplicate primary keys in SQL import?

I have two sites I'm trying to merge. Site 1 has 1500 products in a custom post type, with associated meta and an attached featured image. Site 2 has 250 products in the exact same custom post type, ...
1
vote
1answer
38 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
34 views

Can not manually create a database ( db, user, pass ) for a plugin

So I was working on a plugin and I needed to cache some third party API access, and I needed to manually create a database upon plugin activation or upgrade. The caching stuff needs a database host ( ...
0
votes
1answer
73 views

Custom database query to validate data

I cant find any syntax for custom queries, use of $wpdb is new to me so can anyone help me solving this?? if(isset($_POST['submit'])) { global $wpdb; $tablename='wp_form_subscribe'; $myrows = ...
0
votes
0answers
25 views

Insert query not working for non-logged in user

I am trying to create a function for count post views. for this i have added code in my theme function file. Here is my code: function processpost_views( ){ global $user_ID, $post; ...
0
votes
1answer
33 views

WPDB SQL Ignore `post_status` Parameter

I use this SQL statement: SELECT * FROM wp_posts LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id ) LEFT JOIN wp_term_taxonomy ON ( ...
0
votes
1answer
31 views

Sum of Custom Meta written by Authour

I have a custom meta call post_views_count that collects the views of all posts... I want to create a query that pulls in all posts by a certain author, gathers the custom meta for post views and ...
0
votes
0answers
46 views

Link wordpress with a SQl + MongoDB + .NET

This may sound a bit crazy, I have a website using different DB, One SQl; one MongoDB, and a .net API I would really really love to be able to move this to a wordpress installation ( or Magento). ...