sql简单问题~~(50分)

  • 主题发起人 主题发起人 qrsgroup
  • 开始时间 开始时间
Q

qrsgroup

Unregistered / Unconfirmed
GUEST, unregistred user!
请教,这样的SQL语句怎么些?<br>select top 2 * from info where sex='男' &nbsp;order by rnd(cid)<br>union<br>select top 3 * from info where sex='女' &nbsp;order by rnd(cid)<br><br>order by rnd(cid)随机查询<br>使用联合查询的时候不允许出现2个Order By ...<br><br>该如何随机抽取出2个男的,3个女的???
 
SELECT * FROM (select top 2 * from info where sex='男' &nbsp;order by rnd(cid))<br>union<br>SELECT * FROM (select top 3 * from info where sex='女' &nbsp;order by rnd(cid))
 
select * from<br>(<br>select top 2 * from info where sex='男' &nbsp;order by rnd(cid)<br>union<br>select top 3 * from info where sex='女' &nbsp;order by rnd(cid)<br>)a<br>order by rnd(a.cid)随机查询
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部