gpt4 book ai didi

mysql - Wordpress 自定义 wp_users、wp_usermeta 加入排序不正确

转载 作者:行者123 更新时间:2023-11-29 00:39:01 26 4
gpt4 key购买 nike

我有一个自定义查询,可以使用我编写的统计插件的 user_meta 拉取用户。我可以根据日期范围选择 (WHERE),也可以按任何元字段进行排序,但是,我不能同时进行这两项操作。我快疯了!!这是我的查询(下面有默认变量供引用)...

$getUserData = $wpdb->get_results("SELECT
ID, user_email, user_registered,
first_name.meta_value as first_name,
last_name.meta_value as last_name,
telephone.meta_value as telephone,
country.meta_value as country,
company.meta_value as company,
address.meta_value as address,
city.meta_value as city,
professional_title.meta_value as professional_title,
state.meta_value as state,
areas_of_interest.meta_value as areas_of_interest
FROM wp_users
LEFT JOIN wp_usermeta AS first_name ON first_name.user_id=ID
AND first_name.meta_key='first_name'
LEFT JOIN wp_usermeta AS last_name ON last_name.user_id=ID
AND last_name.meta_key='last_name'
LEFT JOIN wp_usermeta AS telephone ON telephone.user_id=ID
AND telephone.meta_key='telephone'
LEFT JOIN wp_usermeta AS country ON country.user_id=ID
AND country.meta_key='country'
LEFT JOIN wp_usermeta AS company ON company.user_id=ID
AND company.meta_key='company'
LEFT JOIN wp_usermeta AS address ON address.user_id=ID
AND address.meta_key='address'
LEFT JOIN wp_usermeta AS city ON city.user_id=ID
AND city.meta_key='city'
LEFT JOIN wp_usermeta AS professional_title ON professional_title.user_id=ID
AND professional_title.meta_key='professional_title'
LEFT JOIN wp_usermeta AS state ON state.user_id=ID
AND state.meta_key='state'
LEFT JOIN wp_usermeta AS areas_of_interest ON areas_of_interest.user_id=ID
AND areas_of_interest.meta_key='areas_of_interest'
" . $where . "
ORDER BY " . $orderBy . " " . $sortOrder . " LIMIT 0, " . $page_limit);

$where = "WHERE (user_registered >= '" . $_REQUEST['from'] . " 00:00:00' and user_registered <= '" . $_REQUEST['to'] . " 00:00:00') ";

$orderBy = "user_registered";

$sortOrder = "ASC";

最佳答案

提示 - mysql_error()告诉我们,如果您将变量放置正确,您仍然会忘记在那里设置 $page_limit

关于mysql - Wordpress 自定义 wp_users、wp_usermeta 加入排序不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13090934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com