怎样在select中查找。
select a,b,c from table where...
怎样根据a.b.c的各自情况select出a.b.c的数据。
a.b.c是表中的数据,但不是fields。*****************table1
--userid
--username
--userdesc
*****************table2
--userparent
--userid
--usertype (type:1=mother;2=father)
*****************根据userid查找出mother(userid),mother(username),father(userid),father(username).形成4个field.
select a,b,c from table where...
怎样根据a.b.c的各自情况select出a.b.c的数据。
a.b.c是表中的数据,但不是fields。*****************table1
--userid
--username
--userdesc
*****************table2
--userparent
--userid
--usertype (type:1=mother;2=father)
*****************根据userid查找出mother(userid),mother(username),father(userid),father(username).形成4个field.
解决方案 »
- RO Internet难题
- 如何刷新shelltreeview???
- 如何用adodataset控件判断一个表的字段类型?
- 跪求SQL语句!!!
- DLL中Application.ProcessMessages()的问题,进的去却出不来了,我找了好久,也没找到这方面的解决方法呀?
- 如何判断一个机器的ip地址不在规定的号段中,就封锁其ip,谢谢....万分感谢
- 数据库连接问题:
- 请问toolbar中的toolbutton怎样增加图表进去?toolbutton的menuitem是怎么用的?
- delphi7控件listview item单击事件没有反应?
- 新手----游少爷(再问)
- 打开一个 Form时如何向该窗口传递一个参数?
- 请教高手 透明 panel 的实现
from(
select m.userid,m.username,f.userid,f.username
from
(select b.userid as muserid,b.username as musername,a.userid from table2 a,table1 b where usertype=1 and a.userparent=b.userid) m ,
(select d.userid as fuserid,d.username as fusername,c.userid from table2 c,table1 d where usertype=2 and c.userparent=d.userid) f
where m.userid=f.userid
)
where userid=?
select t1.userid as uid, (select ...) as father, (...) as mother,...
from table1 t1, table2 t2
userid username userdesc
001 張三
002 李四
...
②table2
userid userparent usertype
001 張母 1
001 張父 2
...
③結果
select mother(userid)???,decode(usertype,'1',userparent),
father(userid)???,decode(usertype,'2',userparent)
from table1 a,table2 b
where a.userid = b.userid
and a.userid = '001'哥們欠条件、写不出。