select sid,id,' ' cid,st,et,' ' com_name from st_school
union
select '',id,cid,gtdate,'' from st_cert
union
select '',id,'',std,etd,com_name from st_company
order by id;
试试
union
select '',id,cid,gtdate,'' from st_cert
union
select '',id,'',std,etd,com_name from st_company
order by id;
试试
from student a,st_school b,st_cert c,st_company d
where a.id = b.id and a.id = c.id and a.id = d.id;
这样我觉得最合理,也最直观,
楼上的方法似乎没考虑到某些表对同一个学生有多条数据的说。
所以没有使用直接进行关联,这样会出现大量重复数据
union后根据id进行排序后,
每个学生的相关信息就会显示在一起
bzszp(www.bzszp.533.net) 按照您说的union 表可以可以得到,但是在程序端获取好像比较困难,直接关联确实存在重复数据。
困惑……
select id,0, xm, '', sg, tz, sysdate,sysdate from stud where id=1000 union
select id,0, cid,'', 0, 0, gt, sysdate from st_cert where id=1000 union
select id,com_id, '', com_name,0, 0, std, etd from st_company where id=1000 union
select id,sid, '', '', 0, 0, st, et from st_school where id=1000
order by id如果涉及字段太多的话,替换的列是不是很庞大?
这样,在每一种数据前面都加上一个标志,并作成视图
在程序中直接对视图进行检索
create view v_info as
select '1' sign,sid,id,' ' cid,st,et,' ' com_name from st_school
union
select '2','',id,cid,gtdate,'' from st_cert
union
select '3','',id,'',std,etd,com_name from st_company
order by id,sign; 检索时根据id 和 sign进行区分。
不知道有没有别的方法。呵呵,大家帮着出主意。
如果在一个页面显示多个学生的简历,那在查询语句中使用where id in (?,?,?,?)
不确定的学生数目,在数据库中能否改用其它方法?
这个也没有什么关系
谢谢。
在oracle存储过程里面通过动态sql语句来实现
通过ref cursor返回结果集相关内容搜索"动态sql"