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

怎樣尋找欄位中某一特定資料 (SQL statment)

答題得分者是:BOSS
lafite
一般會員


發表:4
回覆:7
積分:2
註冊:2003-08-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-11-21 11:16:57 IP:210.184.xxx.xxx 訂閱
資料庫 : student
學號 成績
3A001 90
3A002 80
3A003 75
3A004 60
3A101 100
3A102 85
3A103 100
3A104 92
3B001 64
3B002 83
3B003 76
3B004 49
3B101 77
3B102 81
3B103 93
3B104 68
| | |
| | |_座號
| |___上午/下午班
|_____班別

Student.Active := False;
Student.SQL.Clear;
Student.SQL.Add('SELECT 學號, 成績 FROM Student');
Student.SQL.Add('where ( copy(學號,1,2) =' '''3A''' ')');
Student.SQL.Add('order by 學號');
Error Msg
'Copy is not a recognized function name'
請問怎樣可以在 SQL Statment 中 找出某一班的成績
BOSS
中階會員


發表:70
回覆:79
積分:64
註冊:2006-11-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-11-21 11:39:44 IP:202.154.xxx.xxx 未訂閱

===================引 用 文 章===================
資料庫 : student
學號????????? 成績
3A001????? 90
3A002????? 80
3A003????? 75
3A004???? ?60
3A101???? 100
3A102???? 85
3A103???? 100
3A104???? 92
3B001???? 64
3B002?? ? 83
3B003???? 76
3B004? ?? 49
3B101???? 77
3B102???? 81
3B103???? 93
3B104???? 68
|??? |? |
|??? | ?|_座號
|?? ?|___上午/下午班
|_____班別

Student.Active := False;
Student.SQL.Clear;
Student.SQL.Add('SELECT 學號, 成績 FROM Student');
Student.SQL.Add('where ( copy(學號,1,2) =' '''3A''' ')');
Student.SQL.Add('order by 學號');
Error Msg
'Copy is not a recognized function name'
請問怎樣可以在 SQL Statment 中 找出某一班的成績

select * from student
where substring(num_,1,2)='3A'
or
select * from student
where left(num_,2)='3A'
BOSS
中階會員


發表:70
回覆:79
積分:64
註冊:2006-11-01

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-11-21 11:40:24 IP:202.154.xxx.xxx 未訂閱

===================引 用 文 章===================
資料庫 : student
學號????????? 成績
3A001????? 90
3A002????? 80
3A003????? 75
3A004???? ?60
3A101???? 100
3A102???? 85
3A103???? 100
3A104???? 92
3B001???? 64
3B002?? ? 83
3B003???? 76
3B004? ?? 49
3B101???? 77
3B102???? 81
3B103???? 93
3B104???? 68
|??? |? |
|??? | ?|_座號
|?? ?|___上午/下午班
|_____班別

Student.Active := False;
Student.SQL.Clear;
Student.SQL.Add('SELECT 學號, 成績 FROM Student');
Student.SQL.Add('where ( copy(學號,1,2) =' '''3A''' ')');
Student.SQL.Add('order by 學號');
Error Msg
'Copy is not a recognized function name'
請問怎樣可以在 SQL Statment 中 找出某一班的成績

select * from student
where substring(num_,1,2)='3A'
or
select * from student
where left(num_,2)='3A'
lafite
一般會員


發表:4
回覆:7
積分:2
註冊:2003-08-29

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-11-21 12:07:17 IP:210.184.xxx.xxx 訂閱
THX... 已經解決到了
whyzn
中階會員


發表:46
回覆:149
積分:54
註冊:2002-06-16

發送簡訊給我
#5 引用回覆 回覆 發表時間:2006-11-25 16:06:21 IP:218.210.xxx.xxx 訂閱
請問 BOSS 兄
我的環境是 XP Delphi5
但是 Query 元件 的 Sql 語法中不能用
Left , SubString 這些函數 不知哪裡需要調整
請指教

===================引 用 文 章===================

===================引 用 文 章===================

資料庫 : student
學號????????? 成績
3A001????? 90
3A002????? 80
3A003????? 75
3A004???? ?60
3A101???? 100
3A102???? 85
3A103???? 100
3A104???? 92
3B001???? 64
3B002?? ? 83
3B003???? 76
3B004? ?? 49
3B101???? 77
3B102???? 81
3B103???? 93
3B104???? 68
|??? |? |
|??? | ?|_座號
|?? ?|___上午/下午班
|_____班別

Student.Active := False;
Student.SQL.Clear;
Student.SQL.Add('SELECT 學號, 成績 FROM Student');
Student.SQL.Add('where ( copy(學號,1,2) =' '''3A''' ')');
Student.SQL.Add('order by 學號');
Error Msg
'Copy is not a recognized function name'
請問怎樣可以在 SQL Statment 中 找出某一班的成績
?
select * from student
where substring(num_,1,2)='3A'
or
select * from student
where left(num_,2)='3A'
------
●○○○○○●○○○○○●
竹密不妨水過,山高無礙雲飛
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#6 引用回覆 回覆 發表時間:2006-11-25 20:17:10 IP:203.204.xxx.xxx 未訂閱
重點不是 XP 或 Delphi
重點是用哪一套 資料庫
將 SQL 語法在資料庫系統中用看看, 是否可行
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
whyzn
中階會員


發表:46
回覆:149
積分:54
註冊:2002-06-16

發送簡訊給我
#7 引用回覆 回覆 發表時間:2007-01-10 21:19:39 IP:218.163.xxx.xxx 訂閱
pcboy 兄
是 paradox
===================引 用 文 章===================

重點不是 XP 或 Delphi
重點是用哪一套 資料庫
將 SQL 語法在資料庫系統中用看看, 是否可行
------
●○○○○○●○○○○○●
竹密不妨水過,山高無礙雲飛
japhen
中階會員


發表:2
回覆:57
積分:71
註冊:2006-08-16

發送簡訊給我
#8 引用回覆 回覆 發表時間:2007-01-11 08:59:02 IP:125.229.xxx.xxx 訂閱
改成 
select * from student
where num_ LIKE '3A%'
幾種SQL伺服器包括ACCESS都可以用

------
歡迎在大陸的台商加入我們的行列
台商小棧 www.twgocn.com
whyzn
中階會員


發表:46
回覆:149
積分:54
註冊:2002-06-16

發送簡訊給我
#9 引用回覆 回覆 發表時間:2007-01-12 12:18:55 IP:218.210.xxx.xxx 訂閱
但是如果要從第n開使取m個字元好像不行 ??
===================引 用 文 章===================
改成
select * from student
where num_ LIKE '3A%'
幾種SQL伺服器包括ACCESS都可以用

------
●○○○○○●○○○○○●
竹密不妨水過,山高無礙雲飛
系統時間:2024-05-19 17:02:25
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!