【发布时间】:2010-08-23 19:47:51
【问题描述】:
我正在努力在表格行中显示分类广告页面。我要解决的问题是以减少页面空白量的方式排列广告,同时保持随机顺序。
几个无序广告的示意图:
_______________ __________________
ad text here. | another ad here
this ad has | (2)
more text than | [ unwanted
that ad. (1) | white-space ]
_______________|__________________
我想做的是按 char_length 对结果进行排序,但还将结果随机分组为 2、3 或其他组。
我现在的查询是:SELECT * FROM ads ORDER BY CHAR_LENGTH(adtext) limit $page, $ads_per_page(使用 PHP)
这给我的结果看起来像:
_______________ ___________________
short ad. (1) | another short ad. (2)
_______________|___________________
ad that's a (3)| another little
little longer. | longer ad. (4)
_______________|___________________
ads keep (5) | this ad has the
getting longer | most text out of
in char_length | all the ads... (6)
这对于减少空白非常有用,但我仍然需要将这些结果随机化。然后在 MySQL 中是否可以将这些结果随机化为 2 组、3 组或其他组?
换句话说,有没有什么东西可以给我如下结果:
_______________ ___________________
ads keep (1) | this ad has the
getting longer | most text out of
in char_length | all the ads... (2)
_______________|___________________
short ad. (3) | another short ad. (4)
_______________|___________________
ad that's a (5)| another little
little longer. | longer ad. (6)
有什么想法吗?
谢谢, 以利
【问题讨论】:
标签: mysql random sql-order-by