如果“$Post_id”=“post_parent”且“user_ID”=“post_author”,那么我需要将“guid”作为变量。但如何呢?
我已经有了这些变量: $post_id(与“post_parent”的值相同) $user_id(与“post_author”的值相同)
在表(我认为它称为表对吧?)“帖子”中,我有三列“post_parent”、“post_author”和“guid”。
但我真的不知道该由谁来做。我已经检查过了,但不知道如何使用它:http://codex.wordpress.org/Function_Reference/wpdb_Class
最佳答案
好吧,我自己做的。 这是工作代码:
$post_id = $info->get_post_ID();
$comments = $wpdb->get_results("
SELECT post_author, post_parent, guid
FROM $wpdb->posts
WHERE post_author = $info->user_id
&& post_parent = ".$post_id."
ORDER BY comment_count
DESC LIMIT 1");
关于mysql - Wordpress 数据库查询 - 根据其他两列从行中获取最新值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25528349/