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

learn more… | top users | synonyms

1
vote
1answer
434 views

Large Woocommerce Site (83,000 items), What Can I Do? [closed]

So I have a really large woocommerce site (partsboss.co) that has around 83,000 items. It's on VPS hosting with digitalocean, and things were running super fast until around 50,000 items. Now the ...
3
votes
2answers
775 views

How to prevent execution of default query, while preserving ability to use WP_Query in template?

PROBLEM: I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries: ...
0
votes
1answer
29 views

Why this query is not showing any result on wordpresss home page?

I am learning wordpress database, And I have written this query for showing the data from the post table with id=2, but not showing anything. What is wrong with the following query? please help. ...
0
votes
1answer
87 views

How to make an sql query to exclude everything but custom taxonomy terms in table wp_terms?

Problem Summary: I am trying to write a SQL query that returns only my custom taxonomy terms, but the table (wp_terms) contains all of the terms, even ones that I don't want (such as category terms, ...
1
vote
1answer
150 views

wpdb insert and boolean fields

I'm preparing an insert query like this: $wpdb->insert('table', $data, $format); data array will be: $data = array_push($data, 'resp' => true) problem is, what $format shall i use for a ...
0
votes
2answers
60 views

Grouping posts by a custom meta value

I'm trying to output a list of dates that are held in a meta key called event_dates without duplicates. I've also tried a wp_query with a meta_compare but I'm not able to make that work either. Any ...
0
votes
2answers
2k views

Alternative to mysql_real_escape_string

I have a WordPress plugin that at one point I need to see if a certain title exists in the database. For 2 years, this code worked fine: $myposttitle= $wpdb->get_results( "select post_title ...
0
votes
0answers
42 views

How to create and display survey and its statistics?

I am making a new website which will basically have 5 questions of Consumer Confidence Index. So my task is to create a survey which should display in homepage take answers for each 5 key questions, ...
0
votes
1answer
42 views

Update postmeta after theme switch

I am trying to update the postmeta table when I switch themes. I am updating the metavalue to be template-name.themename.php. However, this only works with the default themes in wordpress. If I go ...
0
votes
0answers
174 views

Would manually deleting the dumping data fix a “#1062 - Duplicate entry '1' for key 'PRIMARY'” phpMyAdmin error?

I'm new to PHP! I'm trying to import an SQL database file into myPhpAdmin for a WordPress I'm migrating, but I keep getting this error message: SQL query: `-- -- Dumping data for table ...
2
votes
2answers
3k views

Get Previous & Next posts by Post ID

How can I go about getting the previous and next posts from outside the loop? Everything I try to do aside from the custom SELECT query (using get_posts or WP_Query) breaks stuff further down the ...
0
votes
0answers
37 views

Whats the Mysql Query to Find each display_name stored in wp_postmeta.meta_value, grouped by username?

I created a custom content type that contains some fieds tos store user names (display name), thru a meta.key that is called 'opr'. Now i want a mysql query to find all custom postss date ...
0
votes
2answers
55 views

Plugin generating unexpected output - on WP mysql dump import

I am developing my plugin and I am getting this error: The plugin generated 357954 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with ...
1
vote
0answers
128 views

Slow meta_query with about 4 milion record on wp_postmeta

Although optimized wordpress all the way but still very slow as follows : I have converted from LONGTEXT meta_value field to TEXT Then create INDEX for this field ALTER TABLE wp_postmeta ADD INDEX ...
1
vote
2answers
106 views

Single meta_query query using OR instead of AND in request's WHERE statement

I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a meta_query adds an AND clause to the request when what I need is an ...
0
votes
2answers
3k views

WordPress mysqli and PDO

Does wordpress code base use mysqli or PDO? I know PDO is superior to mysqli but mysqli is not bad neither. Plus from one of the features of what makes PDO is superior to mysqli ( that is being ...
0
votes
0answers
23 views

Unable to run wordpress site in WebMatrix after database credential change (db_name, db_user, db_password)

Well, I assumed this would be much easier. I set up wordpress using the Web Platform Installer. It ran with the database it automatically created for me (DB_NAME: wordpress960, DB_USER: ...
0
votes
1answer
91 views

Massive Tags Remove Using MySQL

I am using WordPress 3.4.2 for one of my site and currently it has 38,251 tags Now i want to remove all Tags from my site, so which way will be more safe to truncate every tags my site has.
0
votes
1answer
144 views

How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category

I have tried the following phpMyAdmin query in an effort to delete all posts, from wordpress category 378, that are over 400 days old. delete a,b,c,d FROM wp_posts a LEFT JOIN wp_term_relationships b ...
0
votes
0answers
65 views

Splash pages on a high traffic site

Could use some advice here. We have a fairly high traffic site web site using WordPress. Currently we have two VPS servers managing the site, one that holds WP, one that holds MySQL. The WP servers ...
0
votes
1answer
157 views

How Do I Merge Categories With phpMyAdmin

I tried the following phpMyAdmin query to merge my category 112747 into my category 112748: UPDATE wp_term_relationships SET term_taxonomy_id = 112747 WHERE term_taxonomy_id = 112748; It did not ...
1
vote
1answer
35 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 ...
2
votes
0answers
245 views

How to let a user choose an authors and save it to the database?

I have a multi-author Wordpress site which reads different rss feeds and posts them to my page. I was wondering if it is possible to make a code that would provide an opportunity to registered user ...
2
votes
1answer
78 views

Using $wpdb Class to Pull Recent Comments Across a Network

Been looking for a clean and simple way to produce comments from across a network using the $wpdb database class. I did find this answer, which has been protected, and is four years old. I wrapped ...
1
vote
0answers
68 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
92 views

wp_insert_post another database with custom field

wp_insert_post with the command you want to transfer the contents to another database, I use the following command <?php require('wp-config.php'); $conn = mysql_connect($dbHost, $dbUser, ...
0
votes
1answer
220 views

$wpdb->get_var - What value is returned when zero records are found?

I have the following code: $queryPermission = $wpdb->get_var( $wpdb->prepare("SELECT Active FROM testers WHERE user_id = '$user_id' ")); ...
0
votes
2answers
136 views

Installing local to live WP into subdirectory

I am having a bit of trouble moving a local WP site live and into a subdirectory. I want a static homepage for now (index.html in the root folder) while I work on the live site (would be found in ...
1
vote
1answer
154 views

Wordpress database error - Error in SQL syntax - I can't identify any error?

I am trying to write function that checks whether an email address is stored in my database or not. I've written the following PHP code:: function check_my_users( $email_address ) { global ...
20
votes
6answers
23k views

Using wpdb to connect to a separate database

I want to connect wpdb to another database. How do I create the instance and pass it the database name/username/password? Thanks
0
votes
0answers
79 views

Import posts into SQL

Is there a way to bulk import posts directly into the database? like from csv into sql database. I don't want to use those csv import plugins since they don't always work they either only import half ...
1
vote
1answer
288 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
0
votes
0answers
118 views

SQL query to remove first image in all posts

I've built a site up over a few years (3,500+ posts) where I've inserted images using the traditional method into the post content itself. I'm now moving to a different theme, and have made the first ...
1
vote
1answer
36 views

I want to select the from values from database in WordPress? [closed]

Here is my code: $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'item WHERE uname = "'. $_POST['login_name'] . '" '; $result = $wpdb->get_results($sql) or die(mysql_error()); foreach($result as ...
8
votes
1answer
1k views

Why are simple updates to wp_postmeta's “_edit_lock” so slow?

In our MySQL slow query log, the cumulatively slowest query is a simple update to wp_postmeta. Here's an example: UPDATE `wp_postmeta` SET `meta_value` = '1392835505:386' WHERE `post_id` = 94705 ...
1
vote
1answer
28 views

Why doesn't this code add a table to my database?

To get to the point, I'm trying to add a database table upon installation of my plugin. Here's my code: global $scimp_db_version; $scimp_db_version = "1.0"; function scimp_install () { global ...
-1
votes
1answer
113 views

Remote database -> massive response time increase?

I have nginx web server running newest WordPress and DB server running MySQL 5.6 There is around 90-100ms latency(round-trip delay) between those 2 servers. The problem is that It takes about 5000 ...
1
vote
1answer
86 views

$wpdb->wp_users returning empty value for

I have a code Example: function custom_func(){ global $wpdb; $wpdb->flush(); //tried with and without this line $getTest = 'SELECT * FROM $wpdb->wp_users LIMIT 1'; ...
0
votes
2answers
947 views

Different database query in function.php using mysqli

I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect ...
1
vote
1answer
141 views

How to determine what is generating large amount of database queries?

For some reason, my Wordpress site is using a lot of memory (spiking at 72MB) and generating a huge amount of database queries (76923 according to Wp-Memory-Usage. I'm really not sure why this would ...
1
vote
1answer
128 views

Query Wordpress database by registered date and role

I would like to get the display name and email address for all users who have registered to my multisite today with the role of subscriber. It needs to be an SQL query as it's used outside of the WP ...
0
votes
0answers
70 views

Best way to execute custom page-specific mysql queries

I would like to query a secondary mysql database (not the Wordpress mysql database) with page-specific queries. I've seen many answers / tutorials on setting up a secondary mysql database, like: ...
0
votes
4answers
206 views

Strange wordpress slowness

I read a lot about my problem. I have 4 years old Wordpress (with newest 3.8.1 Wordpress) site. And last months it become really slow. It takes about 3-5seconds to render page. In administration area ...
0
votes
1answer
52 views

wp_postmeta - lot of meta fields

I found a lot of meta_key + meta_value fields in my database in wp_postmeta. They are all same only meta_id and post_is changign. And there is more than thousands of them. Look at the pic. Should I ...
0
votes
0answers
21 views

Archive list with only years and months belonging to a category

I need to generate a list of years and months belonging to a category. For example I have two main categories (A and B). I need a list of years and months of post published only of the category A and ...
1
vote
2answers
2k views

Help with MySQL to $WPDB query

Here's my issue. I have three tables I'd like to query - states, points, and state_points. States contains stateid, and name. Points: pointid, pointlat, pointlng. State_points: Stateid, Pointid. ...
2
votes
2answers
118 views

WordPress for a very large website

I've searched and searched but I did not find an answer online. Also, I've posted this on StackOverflow and apparently it wasn't ok and I reposted this here. I hope it's ok. I have this website which ...
0
votes
1answer
176 views

Updating User Meta with SQL Query

I have a Wordpress site that needed to have 9,000+ users imported to set up a Directory Listing. I imported them from an existing MySQL (non-wordpress) database and everything imported just fine. ...
1
vote
0answers
147 views

MySql Query very slow

I have a problem with a query on my website. When I load the page it is incredibly slow and only after over 12 seconds the content starts showing. I have installed a debug plugin and found the query ...
0
votes
2answers
959 views

Woocommerce: Grab total revenue of a product over all orders

I need to display the total revenue of all orders for my products depending on if the logged-in user is the author of the product or not. I can't use the Quantity field as a multiplier either because ...