P
P
Pashenka2014-05-07 22:14:24
MySQL
Pashenka, 2014-05-07 22:14:24

How to fix SQL query in WordPress database

Good evening,
I'm not savvy in sql, but you need to execute such a query:

UPDATE wc_term_taxonomy SET count = (SELECT COUNT(*) FROM wc_term_relationships, wc_posts WHERE 
wc_posts.ID = wc_term_relationships.object_id AND post_status = 
'publish' AND post_type = 'lyrics' AND term_taxonomy_id = '1229');

those. we update the number of posts of a certain type for taxonomy, since I generate a .sql database dump without taking into account this data, this column has zeros, and this is no good.
Tell me how to correct the request so that it goes through all the term_taxonomy_id and writes them into the corresponding cells of the wc_term_taxonomy table?
Just in case the table structure is:
wc_term_relashionships:
object_id | term_taxonomy_id ...
wc_posts:
ID | ...
wc_term_taxonomy:
term_taxonomy_id | term_id | count...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
romashka_sky, 2014-05-08
@like-a-boss

... AND post_type = 'lyrics' AND wc_term_taxonomy.term_taxonomy_id = wc_term_relationships.term_taxonomy_id);

did not check

F
Facetrollex, 2014-05-07
@Facetrollex

put it awayAND term_taxonomy_id = '1229'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question