简体   繁体   English

Select ID 是“随机”的东西

[英]Select something where ID is “random”

I already searched for random ID.我已经搜索了随机 ID。 It seems I HAVE to select a random row?看来我必须 select 随机行? I don't quite understand it yet.我还不太明白。

What I want to do is to select tid , preis from the stickythread from a random ID or row.我想要做的是preis tid ,来自随机ID或行的粘性线程。

$sql="SELECT tid,preis FROM stickythread WHERE id=1";

Is there a simple way to get a random ID from 1 to 3, without changing to much?有没有一种简单的方法来获得从 1 到 3 的随机 ID,而不会改变太多?

I thin that you mean:我认为你的意思是:

select tid, preis 
from stickythread 
where id between 1 and 3 
order by rand() limit 1

The query filters on id between 1 and 3 , then order by rand() shuffles the results, and limit 1 keeps the first row only.查询过滤id介于13之间,然后order by rand()打乱结果, limit 1只保留第一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM