藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 數 據 庫


    

藍森林 http://www.lslnet.com 2006年7月08日 11:08


如何寫多條記錄取一條的sql

我執行:
select  phonenum, smtext from sm_tb_send_log where sendflag ="N"
and smtype!="4"
and sendid=(select min(sendid) from sm_tb_send_log  where  smtype=!"4" and sendflag ="N")
出現錯誤提示:
ct_cursor(CLOSE): user api layer: external error: A cursor must be opened before this command type can be initialized.
是什麼原因,如何解決?
或者,幫我想個從N條記錄的表a中取出id值最小的那條記錄!
拜託 !!!

如何寫多條記錄取一條的sql

select * from a group by id having id=min(id)

如何寫多條記錄取一條的sql

我試過,問題沒解決呀!而且,可以不用group by 麼?

我的表是:
id ,name ,flag  3列
數據為:
id     name    flag
1      a            N
2      b            N
3      c             Y  
我只要將第一條flag='n'的數據提取出來。這裡應該提取的是id為1的記錄。
謝謝幫忙!

如何寫多條記錄取一條的sql

set rowcount 1.


select * from ... order by id.

如何寫多條記錄取一條的sql

發表於: 2004-10-21 10:10    發表主題:   

--------------------------------------------------------------------------------

select * from  a  having id=min(id)
對不能用group



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com