[wizs] 新指令 select
程式名: /cmds/wiz/_select.c
程式行數: 230 (所以它是小程式,而且還沒最佳化)
> select
select(Sanc SQL)指令說明:
=========================================================================
select 資料名 from 資料庫
select 資料名1,資料名2,.. from 資料庫
select 資料名 from 資料庫 where 某資料名 = 某值
select 資料名 from 資料庫 where 某資料名 = 某值 order by 某資料名 [desc]
資料名例: level, race, stat, stat/con, ...
資料庫例: users, livings
==========================================================================
Laechan@Sanc in 2008/11/07
例一:
從 玩家 中挑出 種族 為 elf 的, 秀出其 name、gender、race, 並照 hp_src 大小排列
> select gender,race,hp_src from users where race = elf order by hp_src desc
name gender race hp_src
========================================================
luri female elf 1007322
i female elf 794556
uki female elf 533021
maiden female elf 528292
angelo male elf 446397
laechan male elf 435611
aton female elf 425970
natname female elf 419628
doreen2 female elf 417618
weapon female elf 407167
例二:
從 怪物 中挑出 等級 > 200 的, 秀出其 等級 及 名稱, 並照 等級 由大而小
> select level from livings where level > 200 order by level desc
level short
========================================================
255 傑爾克(Jerec)
255 織依(Clovers)
255 格克(Gorc)
255 穿著聖誕老人裝的的肉粽伯(ThomgthMan)
255 緹西拉.德古拉(Tessera)
255 死神─迪斯(Death)
255 惡靈劍士(Swordsman)
255 地獄大元帥(General)
255 守衛隊長兼訓練師傅莫登(Morden)
從 怪物 中挑出 等級 > 200 的, 秀出其 等級 及 名稱, 並照 等級 由小而大
> select level from livings where level > 200 order by level
level short
========================================================
201 絕世天魔(Fulltwinevil)
201 泥人(Mudperson)[7個泥人]
201 黑無常(bgargoyle)
202 夏克兒(Ice-SnowEvilnessMaster)
203 北地禁衛軍(northguard)
203 石巨人(Stoneman)[10個石巨人]
205 謨(Maw)
206 巨大兵蟻(Soldierant)[5隻巨大兵蟻]
206 鐵甲武士(ironguard)
206 魔偶操術士(DollMaster)
208 巨型史萊姆(slime)
例三:
一次秀出玩家的多種資料
> select level,gender,race,pri_guild,ethic,warexp from users where level = 120
name level gender race pri_guild ethic warexp
============================================================================
lucifa 120 female elf clerical 28 UNDEFINED
fancylants 120 male devil mage 1005031 4882
cristine 120 male devil mage 216104 2256
note3 120 male elf mage 1102787 7405
kamina 120 male human blader 64872 15260
koloyas 120 male devil slasher 515595 3375
doof 120 male stoneman fister 1182797 131728
laechan 120 male elf slasher 5000000 9593
dofela 120 female elf clerical 126613 UNDEFINED
cloudwu 120 female human fister 1153211 7600
run 120 female devil clerical 5000000 710439
例四:
秀出單一玩家資料
> select level,hp_src,sp_src,pp_src from users where name = bahamudo
name level hp_src sp_src pp_src
========================================================
bahamudo 120 730377 1223067 715276
一、where xx < oo 的部份還沒寫(複製貼上即可).
二、系統自動對 livings 做 group_by 的動作(避免 q 出多個一樣的怪物)
三、我打算新增 eqs 及 wps 及 objs 三種資料庫
四、where xx1 = oo1 & xx2 = oo2 ... 這個能做的話會盡量做出來.
五、當然我會希望它能顯示較佳的排版
六、我會試看看能否 select 出 戰鬥力 這樣的東西, 或者在 order by
時能否以戰鬥力做為 order by 的依據(或者 技能數 這樣的東西)
(不過這個只限在資料庫為 users 時, 這應該做的到)
七、我可能會新增一個語法,它可以挑出某資料含有特定關鍵字的資料
> select xxx from livings where short contains guard order by level desc
可以讓程式去找名字(含ID)中有 guard 的所有怪物再依 level 做篩選
在某些方面這個東西比 checking 好用, wiz.3 以上的巫師可自行試試,
若原先你不會 sql 語法的話,透過練習這個指令,你有機會很快上手sql
語法。
寫這東西還有另一個目的,例如我想做相關資料的綜合查詢時,這個很方
便,例如同時 select 出玩家的 sword, swordmaster, nine-sword 等做
列表.
(不過目前判斷還沒寫的很嚴謹)
Laechan
--
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 編輯: laechan 來自: 118.170.105.31 (11/08 01:35)
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章
35
58
120
255