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
1answer
2k views

Using AJAX to run SQL statement and populate dropdown

I am trying to create a search where the user selects two different bits of data from the database and it then prints some results that meet requirements. I know I need to use AJAX, or something ...
0
votes
0answers
7 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
38 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
27 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
25 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
1answer
28 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
0answers
20 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
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
1answer
418 views

How in insert image path in Wordpress database that will display product image in wp admin not on front end?

$insert = $wpdb->insert( $prefix."posts", array("post_title" => $posTitle,"post_content" => $postContent,"post_status" => "publish","post_type" =>"product")); // select products ID ...
0
votes
2answers
3k views

SQL - Pull products of particular category from a remote WordPress woocommerce db

I connected to the db and successfully pulled products data. Now I want to to display products from specific category. The store is using woocommerce. The landing page is in different location so I ...
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
2answers
25 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 ...
0
votes
2answers
488 views

Bulk move (or copy) from a custom field to the post content?

I need to move (or copy) the contents of a custom field into the main post body, replacing any existing content. I need to do this for a few hundred posts...Is there a quick way of doing this? I can ...
0
votes
1answer
509 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
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
23 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
1answer
486 views

When sorting WP_List_Table, table sorts, but I also get SQL errors

Here's my lovely prepare_items() function: function prepare_items() { global $wpdb; $table_name = $wpdb->prefix . 'blah'; $per_page = 100; $columns = $this->get_columns(); ...
0
votes
0answers
18 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. ...
10
votes
8answers
51k views

What SQL Query to do a simple find and replace

Whenever I create a new website I first create a staging site on a subdomain like "stage.domain-name.com". After everything works correctly I export the database, open it in notepad++ and do a ...
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
75 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
33 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 ...
1
vote
2answers
2k views

how to use $wpdb->prepare to update a custom table

As a noob I dont understand a lot of SQL injections but I need to be save so I have read that I have to use wpdb->prepare to make sure the data is stored correct. At this moment I use the ...
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) , ...
1
vote
1answer
145 views

Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin

I have a wordpress table like so (phpmyadmin and MySQL) | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | ...
0
votes
0answers
13 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
110 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
70 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, ...
3
votes
3answers
7k views

Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working ...
1
vote
1answer
51 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 ...
2
votes
1answer
1k views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
6
votes
2answers
112 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 ...
5
votes
2answers
169 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
71 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
29 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 ...
15
votes
5answers
30k views

WP_Query with “post_title LIKE 'something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( 'post_type' => 'wp_exposants', ...
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
1answer
312 views

Can't create posts with WP DB Abstraction Plugin

I have a WordPress site moved to Azure web site + Azure SQL using database abstraction plugin After that migration I'm not able to create new posts. When I click Save Draft it redirects me to the ...
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 ...
5
votes
1answer
1k views

get_results on large datasets

I am experimenting some very disturbing problem using a custom SQL query. I have a custom MySQL table called trading_datas having 165 lines for 4,4Mo. One field datas of my table is a big serialized ...
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 ...