Wordpress 获取值之间的最大 post 元数据

Wordpress get max post meta between values

我已经有这样的查询:

SELECT max(cast(meta_value as unsigned)) AS max_racer_nr FROM wp_postmeta WHERE meta_key='racer_nr'

我需要得到最大值 racer_nr,它介于 1 - 99100 - 199,或 200 - 999 取决于 class 赛车属于哪个到.

SELECT MAX(CAST(`meta_value` AS unsigned)) AS `max_racer_nr` FROM `wp_postmeta` WHERE `meta_key` = 'racer_nr' AND `meta_value` BETWEEN 1 AND 99; 

SELECT MAX(CAST(`meta_value` AS unsigned)) AS `max_racer_nr` FROM `wp_postmeta` WHERE `meta_key` = 'racer_nr' AND `meta_value` >= 1 AND `meta_value` <= 99; 

您只需根据赛车手的 class 更改 PHP 代码中的值。除非我误解了你的需要。