全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:706
推到 Plurk!
推到 Facebook!

Self joins

尚未結案
syene
一般會員


發表:17
回覆:12
積分:5
註冊:2003-01-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-06-07 23:16:02 IP:220.138.xxx.xxx 未訂閱
一個Access table : Elements 其schema如下 : Tid:Auto term:char(32) begin:long end:long level:long, 當下面的sql執行時, select * from Elements e1, Elements e2 where e1.docno=e2.docno and e1.term='plant' and e2.begin〉e1.begin and e2.end〈e1.end and e2.level =e1.level 1 and e2.term='name' order by e2.docno,e2.begin 發生「無法指出的錯誤」 若將and e2.end〈e1.end這一行去掉, 可執行但結果集是錯誤的, 請問這是sql的問題, 還是access的問題? 如果非下and e2.end〈e1.end這行不可, 可有解決知道? 謝謝‧ 發表人 - syene 於 2005/06/07 23:16:43 發表人 - syene 於 2005/06/07 23:19:45 發表人 - syene 於 2005/06/07 23:21:26
timhuang
尊榮會員


發表:78
回覆:1815
積分:1608
註冊:2002-07-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-06-08 22:52:31 IP:220.132.xxx.xxx 未訂閱
Hi, 請將 end 加上 [] 即可, 如, select * from Elements e1, Elements e2 where e1.docno=e2.docno and e1.term='plant' and e2.begin>e1.begin and e2.〔end〕<e1.〔end〕 and e2.level =e1.level 1 and e2.term='name' order by e2.docno,e2.begin 應該是 end 在 delphi 中視為關鍵字!! 直接在 access 中下是沒有問題的! 發表人 - timhuang 於 2005/06/08 22:54:27
syene
一般會員


發表:17
回覆:12
積分:5
註冊:2003-01-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-06-09 22:46:26 IP:220.136.xxx.xxx 未訂閱
謝謝timhuang, 其實在po完本文之後,懷疑應該是欄位名稱衝到關鍵字, 於是將end改成enda,竟然可以,但畢竟使用您提供的方法, 是較具意義的,因為保留欄位名稱的實質意義, 只是有點懷疑的是,為何begin卻不會造成該等情形? 還有加上[]的用法,是何意義,另外是在delphi的使用時機? 因為我這些SQL command是放在AdoDataSet中的commandtext屬性中執行, 再次感謝,讓我學到在delphi中, 下sql command的另外表達方式.
引言: Hi, 請將 end 加上 [] 即可, 如, select * from Elements e1, Elements e2 where e1.docno=e2.docno and e1.term='plant' and e2.begin>e1.begin and e2.〔end〕<e1.〔end〕 and e2.level =e1.level 1 and e2.term='name' order by e2.docno,e2.begin 應該是 end 在 delphi 中視為關鍵字!! 直接在 access 中下是沒有問題的! 發表人 - timhuang 於 2005/06/08 22:54:27
cancer
高階會員


發表:58
回覆:319
積分:190
註冊:2004-07-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-06-09 23:12:40 IP:210.201.xxx.xxx 未訂閱
我想應該不是 SQL 敘述中含有Delphi的關鍵字 end的關係,因為Delphi有能力知道這個end是出現在SQL敘述當中。
系統時間:2024-06-29 16:51:13
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!