0
下面的SQL語句有點正確地對我的結果進行排序,但它沒有考慮小數點......我該怎麼做?通過數值對SQL語句中的行進行排序不會帶小數
37.5應該在最上面。
SELECT * FROM wp_postmeta WHERE meta_key = 「win_percentage」 ORDER BY meta_value DESC
Array
(
[0] => Array
(
[meta_id] => 417
[post_id] => 59
[meta_key] => win_percentage
[meta_value] => 9.3023255814
)
[1] => Array
(
[meta_id] => 419
[post_id] => 62
[meta_key] => win_percentage
[meta_value] => 6.66666666667
)
[2] => Array
(
[meta_id] => 425
[post_id] => 64
[meta_key] => win_percentage
[meta_value] => 37.5
)
[3] => Array
(
[meta_id] => 433
[post_id] => 68
[meta_key] => win_percentage
[meta_value] => 36.5079365079
)
[4] => Array
(
[meta_id] => 421
[post_id] => 58
[meta_key] => win_percentage
[meta_value] => 32.8767123288
)
[5] => Array
(
[meta_id] => 423
[post_id] => 63
[meta_key] => win_percentage
[meta_value] => 16.6666666667
)
)
什麼類型的字段是meta_value?浮點數,小數點還是varchar? – aynber
它看起來像一個字符串排序... – Random
它的varchar這一切都在wordpress中,所以varchar非常強迫。 –