思路:
先将取出的值随机排序,然后在随机排序的每次取第一条的结果
举例如下:
select * from(select t.code fromTBIZOPS_PROVINCE t ORDER BY DBMS_RANDOM.RANDOM())where rownum < 2;
select * from (select t.code from TBIZOPS_CITY t wheret.province_id = ‘13‘ ORDER BY DBMS_RANDOM.RANDOM()) where rownum< 2 ;
select * from (select t.code from TBIZOPS_County t wheret.province_id = ‘13‘ and t.city_id = ‘1304‘ORDER BYDBMS_RANDOM.RANDOM()) where rownum < 2 ;
原文地址:https://www.cnblogs.com/fppblog/p/9414194.html
时间: 2024-11-05 18:29:51