Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update with limit of 15 post on wordpress

Author  Topic 

gandolfi
Starting Member

2 Posts

Posted - 2009-05-24 : 04:22:13
hello,

i'm a french user of wordpress and i want to UPDATE draft post to publish but there is few condition.

Table : "wp_posts"
rows : "post_author", "post_date", "post_status" and "post_category"

- i want to edit 15 post/day/different autor -> UPDATE "post_status = draft" to "post_status = publish"
- I want, at maximun, in the 15 post : one post by author different per category. I want to avoid there is more of one post per day of the same autor in a category.
- I want to start the update with the oldest post.

i have try with this but i have not the limit of 15 and the ORDER BY post_date ASC.

CREATE TEMPORARY TABLE tmp_posts_ignore 
SELECT post_author, post_categorie
FROM wp_posts
WHERE post_status='draft'
GROUP BY post_author, post_categorie
HAVING Count(*)>=2;

UPDATE wp_posts SET post_status='publish'
WHERE wp_post_status='draft'
AND (post_author, post_categorie) NOT IN (
SELECT post_author, post_categorie
FROM tmp_posts_ignore
);


thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-24 : 04:25:23
This is a Microsoft SQL Server forum.
If you are using MySQL, please try over at www.dbforums.com


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

gandolfi
Starting Member

2 Posts

Posted - 2009-05-24 : 05:01:23
sorry, i will post on another forum
Go to Top of Page
   

- Advertisement -