作者alexcwtzeng ()
看板Database
标题Re: [SQL ] 请问这样的查询条件要怎麽写比较好
时间Wed Mar 19 16:55:16 2008
※ 引述《erho (ptt访客)》之铭言:
: 我资料库是ORACLE
: 有2个TABLE
: TABLE A
: --------
: BED_NUM
: ATTENDING_CODE
: NURSING_CODE
: TABLE B
: -------
: CODE
: PRICE
: BED_NUM是TABLE A的主KEY,CODE是TABLE B的主KEY
: 若要做一个以TABLE A的BED_NUM做查询条件要查该BED_NUM的
: ATTENDING_CODE及NURSING_CODE的PRICE有没有办法用一个SQL语法查出来
: (ATTENDING_CODE及NURSING_CODE的PRICE在 TABLE B)
根据您的说明,小弟还是有一些不太懂的地方。
但是如果单纯从字面上的要求,应该是可以用如下的 SQL 达成吧...
请试试 ^^"
select t1,bed_num,
t2.code attending, t2.price attending_price,
t3.code nursing, t3.price nursing_price
from a t1,
b t2,
g t3
where (t1,attending_code = t2,code or
t1,nursing_code = t3,code)
and bed_num = &inputed_bed_num;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.125.179.204
※ 编辑: alexcwtzeng 来自: 59.125.179.204 (03/19 16:58)
1F:推 gargamel:.跟, 03/19 19:08