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)

-4
votes
0answers
14 views

write a generic script which allows any database in the box and output as below [on hold]

Write a generic script which allows any database in the box and output as below. Database is running in host < > since <> Following are the details: # DB Name : TEST Version ...
0
votes
2answers
843 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
1answer
450 views

Inserting Post Meta From SQL

I'm trying to get post meta to be updated/replaced with $wpdb and running into issues. I have working SQL, but cannot get it work when coding it up for my WP plugin. Extra note: The post meta being ...
0
votes
2answers
972 views

Up/Down voting system for Wordpress

Looking in all posts with keywords "voting system, upvote, downvote", I can't find a satisfying solution for this issue, except accepting one of the available plugins, spend a lot of time undersanding ...
0
votes
0answers
40 views

WordPress get pagination on wpdb get_results

This is my favorites page codes. How do I gee the numbered pagination of custom wpdb result? $query ="SELECT * FROM wp_posts as p, wp_postmeta as m WHERE p.ID = m....
0
votes
1answer
28 views

Plugin Development sqlite or WordPress' database

I am developing a plugin for WordPress that has to store between 4.5-200mb of data. I thought of using sqlite to store and access the data instead of using WP's database. From a performance ...
0
votes
1answer
429 views

How to set search query for joining two tables in sql?

What's the wrong with this query? SELECT l.company_name,DISTINCT c.sub_cat_name FROM tbl_listing l,tbl_sub_category c WHERE l.company_name LIKE '%cy%' and l.city_id='2' and l.area_id=23 ORDER BY l....
0
votes
0answers
10 views

Select metakey values from WP database only where posts are published (two tables)

I am trying to select metakey values from wordpress database like this: global $wpdb; $r = $wpdb->get_col( $wpdb->prepare( " SELECT meta_value FROM {$wpdb->postmeta} WHERE ...
6
votes
1answer
1k views

$wpdb->get_results(…) returns empty array despite correct query

As title implies, I cannot seem to get $wpdb->get_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason. global $wpdb; ...
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 ...
1
vote
0answers
435 views

SQL query equivalent to WP User Query

I have the following WP user query code: //Get all users sorted by whatever $sorted_users = new WP_User_Query(array( 'orderby' => 'meta_value', 'meta_key' => 'satisfaction_rating', '...
1
vote
1answer
34 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 ...
3
votes
2answers
1k views

Display only certain posts based on visitor's country?

Is it theoretically possible to have the following feature? Each post has a country code. When a visitor comes in, the system will determine the visitor's country code. Then when the page renders, ...
0
votes
1answer
29 views

How to make MySQL search queries with quotes

Hi everybody I run a wordpress based website and I'd like to store the search queries called by users to use them as analytics data to know what's most searched etc... So I have a custom table where ...
0
votes
0answers
37 views

How can i change posts dates random?

I have totaly 5k content. I need change all of them dates. How can i set randomly dates? SQL? Example from 01.01.2010 to 20.06.2016 everyday can be dates.
1
vote
1answer
29 views

Archive post by meta value + 24hours

I'm using this code to archive some custom post type : $where .= " AND wp_postmeta.meta_value >= now()"; The metavalue is a date field. On the day of the value of the datefrom has been setup the ...
2
votes
0answers
35 views

my function doesn't return my post from today

I'm using gravity form to create some custom post type - as events. Everything is working great, There is some date field to setup the event from x to y date. ALl of this working great. However, I ...
0
votes
0answers
45 views

Advanced search query select from custom table

Hope that anyone can help me with this problem. I have 7 columns in my tbl2014wines custom Wordpress table. I am trying to create an advanced search feature that allows users to search by wine_name, ...
0
votes
0answers
106 views

I want to query for the 'post' and 'attachment' in wordpress using SQL query

How do I write a SQL query which will allow me to query for the 'post' and 'attachment' at the same time in MySQL? I am trying to get this information from the wordpress 'Posts' table. Please see my ...
0
votes
0answers
19 views

Combined filters

I have a problem and i'm really stuck on this one. I have a small 'woodshop' and i want people to filter the results. The case: When i check multiple brands, the types should be updated. But when i ...
0
votes
1answer
18 views

Add commentmeta custom field to every published comment with SQL

I am trying to add custom commentmeta "likes" with 0 as default value to every posted comment. I have this query but I dont see any error there, but still it doesnt work. Can anyone help me to solve ...
1
vote
2answers
44 views

Need help writing a $wpdb query

I am trying to search through post meta for keyword matches but I'm new to MySQL and I don't know how to write my query. I can write a basic query for post_title matches but I don't know how to ...
0
votes
1answer
40 views

I can't write in my DB using $wpdb->insert

Building a plugin I'm trying to insert something in my DB but isn't works! My code is like that: global $wpdb; $table_name = $wpdb->prefix."mytable"; $wpdb->insert( $table_name, array(...
0
votes
0answers
261 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). ...
2
votes
0answers
31 views

SQL Query to copy value of a meta_key into another meta_key

I am trying to figure out how to replace the value of one advanced custom field with the value from a different custom field. Would anyone be able to help me structure a SQL query that will do this ...
1
vote
2answers
107 views

How to find meta entries with their posts missing via SQL?

I'm looking to write an SQL query to do the following: Select all postmeta rows where the meta_value = a post id that does not exist. For example, postmeta meta_value may equal 235. Usually this ...
0
votes
1answer
42 views

How do I get my suggest to only suggest one taxonomy?

I am using the built-in wordpress suggest plugin to call the entries from the terms table. Using the following sql query it spits out all terms: $query = 'SELECT term_id,name FROM ' . $wpdb->...
0
votes
0answers
16 views

Use remote image URLs as featured images/thumbnails [duplicate]

I'm working to migrate a site from Drupal (version 6) to WordPress (4.5.1). It has ~50,000 posts, almost all of which have one main image that appears in a large version on the post itself, and in a ...
1
vote
0answers
30 views

The word 'exit' in a content box causes WordPress to serve a 'Not Found' page [closed]

I've been developing with WordPress for years, and this is a new one. When the word 'exit' is included in the content of a post, even if inside another word like 'complexity', the post will not save. ...
0
votes
1answer
45 views

wpdb query on custom table not working [closed]

I want to show one custom table from my database on which WordPress is installed. So I googled this code: <?php $results = $wpdb->get_results( $wpdb->prepare("SELECT * FROM sparte-...
0
votes
1answer
36 views

Update field name without losing the value

So I have this photography website using ACF with flexible content. It has approximately 300 posts. Due to requirements, I need to update the name of some fields. I've tried the following query: ...
0
votes
1answer
32 views

Scheduling posts in database

I have more than 100 posts to schedule. I have set the date and the status (future) with a SQL query. But when the time comes the post is not published and in desktop I can read message 'Schedule lost'...
0
votes
2answers
44 views

WPDB Placeholders and second argument for prepared statements

How can I set placeholder and second argument for that kind of sql prepare $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND ID IN ('".implode("',...
0
votes
0answers
32 views

Storing Unique Data on the Database

I have created a custom table on my database using the code below: function dbcreator_activate() { global $wpdb; $table_name = $wpdb->prefix . "ftbstatistics"; if( $wpdb->get_var('...
0
votes
0answers
34 views

Custom database query with accents returning no results

I have an issue where using accents in my custom database query (wpdb) returns no results. $wpdb->get_results( "SELECT * FROM table WHERE city = 'Montréal'" ); Returns nothing, while $wpdb-&...
13
votes
8answers
69k 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 find/...
0
votes
1answer
54 views

wpdb get posts by taxonomy SQL

I need a list of posts of a specific post_type plus the name of a custom taxonomy term. This is what I got so far SELECT p.post_name,t.name as clientName FROM $wpdb->posts AS p, $wpdb->terms ...
0
votes
0answers
29 views

send email to user

I want to send an email to users based on the value of the database. To clarify if the user exceeds the value set in database, send him an email Automatic But I do not know where to write the code in ...
0
votes
0answers
22 views

Function get_results doesn't working

This is very very strange, 'cause when I run this query in my MySQL terminal, works perfectly: Query: "SELECT a.post_id, a.meta_value, a.meta_key, b.meta_key, b.meta_value FROM pdb_postmeta AS a ...
0
votes
1answer
117 views

Get all child comments ids from parent comment id

I want to get all child comments ids from parent comment id. Do i have to write custom sql or can i use get_comments() to achieve the following output. eg 1 I want to get 2,3,4,5,6,7,8 ids from ...
0
votes
0answers
22 views

Limit results of custom query to current category

I have created a geolocation system for a custom post type of services and have been working on a query to limit the results based on address/distance entered by the user. Everything seems to be ...
-2
votes
2answers
570 views

SQL query to check whether a meta key is set or not for a post in post_meta table

Condition: some post have meta_key 'status'. Please help me in with this condition: sql query for those post who don't have meta_key 'status'
0
votes
3answers
52 views

Get all posts from db between 2 specified months

Am trying to get wp posts between two specific calendar month. The problem is, it is a annual year. So month starts from May and ends in Next year April. So each year output should start from May of ...
0
votes
1answer
30 views

Use variable in SQL statement

I have this: <?php $jerseys = $wpdb->get_results("SELECT order_item_id, order_id FROM wp_woocommerce_order_items WHERE order_item_name = 'Mystery Jersey'"); echo "<p>Jerseys</p>"; ...
0
votes
0answers
17 views

Why Do I Still Getting Duplicate Rows in SQL?

I'm creating a Custom Freight System which stores the order and the products requested by the user into the WordPress Database. The Problem When I insert the product into the wp_my_custom_products ...
-1
votes
2answers
1k views

Change Login URL Without Plugin

I want to change the login url of my Wordpress install away from /wp-admin.php I am aiming to do so and am looking at changing the .htaccess file to add in: RewriteRule ^login$ http://yourdomain.com/...
0
votes
2answers
100 views

What to create new post using wp_insert_post, but it repeat the post infinitely

this is my source global $page; $page_exists = $page->post_title; $another_db_user = 'user'; $another_db_pass = 'pass'; $another_db_name = 'name'; $another_db_host = '...
0
votes
2answers
108 views

Wordpress wpdb->insert returns int(0) => doesn't insert anything, no errors!

I am really clueless. I want to do an insertion in my WordPress plugin the problem is it doesn't return any errors nor it insert the stuff! I don't know how to fix this and really need your help. In ...
1
vote
1answer
101 views

How change user type from contributor to author

I have 2058 users who are contributors. I need to convert their role to author. How can do it by SQL?
0
votes
0answers
20 views

WP_QUERY with alternating post types and pagination [duplicate]

I want to show both regular posts and a custom post type (event) on the homepage in a single loop. The event post type needs to be ordered by a custom field for the event date and show future events. ...