我想在我的wordpress插件中更改这个查询,以便它从100行中随机检索30行。
$query = $wpdb->prepare("
SELECT
p.*, qq.quiz_id, qq.question_order AS order
FROM
{$wpdb->posts} p
INNER JOIN
{$wpdb->prefix}learnpress_quiz_questions qq ON p.ID = qq.question_id
WHERE
qq.quiz_id IN (" . join( ',', $format ) . ")
AND
p.post_status = %s
", $args );
我把它改成了这个,但还是不起作用。有人能帮我吗?
SELECT
p.*, qq.quiz_id, qq.question_order AS order
FROM
{$wpdb->posts} p
INNER JOIN
{$wpdb->prefix}learnpress_quiz_questions qq ON p.ID = qq.question_id
WHERE
qq.quiz_id IN (" . join( ',', $format ) . ")
AND
p.post_status = %s
ORDER BY
RAND() LIMIT 30
1条答案
按热度按时间3lxsmp7m1#
将您的排序更改为以下内容:
或者如果您有一个整数id: