답변 4개
채택된 답변
+20 포인트
11년 전
데이터가 많을때 rand는 부하를 많이 차지합니다
select * from aabbcc where bo_table = 'abc' order by rand() limit 1
아래처럼 수정해 보세요
(select * from aabbcc where bo_table = 'abc') order by rand() limit 1
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
11년 전
</p>$sql = " select count(*) cnt from aabbcc where bo_table = 'abc' ";<div>$result = sql_query($sql);</div><div>$row = sql_fetch_array($result);</div><div>$sql = " select * from aabbcc where bo_table = 'abc' limit ".rand(0,$row['cnt']-1).',1';</div><div>$result = sql_query($sql);</div>$row = sql_fetch_array($result);<p><span style="font-family: 돋움, Dotum, Helvetica, sans-serif; font-size: 12px; line-height: 1.5;">
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인