Select y. *, z. Z_NAME, j. JS_NAME from t_yonghu y, t_zhan z, t_juese j where y. fk_z_id = z. z_id and y. fk_js_id = j. js_id
Select y. *, z. Z_NAME from t_yonghu y, t_zhan z where y. fk_z_id = z. z_id
Union
Select y. *, B. BZ_NAME from t_yonghu y, t_banzu B where y. fk_bz_id = B. bz_id
Union
Select y. *, j. JS_NAME from t_yonghu y, t_juese j where y. fk_js_id = j. js_id
Union
Select y. *, bu. BM_NAME from t_yonghu y, t_bumen bu where y. fk_bm_id = bu. bm_id
String SQL = "select yh_id, yh_username, yh_mima, values (fk_z_id) z_name, fk_bz_id, fk_js_id, fk_bm_id, yh_name from (select rownum r, t1. * from t_yonght1 where rownum <: y_to) t2 where t2.r>: y_from ";
Final query function:
Create or replace FUNCTION Get_BM_name_BY_ID
(
Zid in number
)
RETURN nvarchar2
Zname nvarchar2 (100 );
BEGIN
Select t. bm_name into zname from t_bumen t where t. bm_ID = zid;
RETURN zname;
END Get_BM_name_BY_ID;
Create or replace FUNCTION Get_BZ_name_BY_ID
(
Zid in number
)
RETURN nvarchar2
Zname nvarchar2 (100 );
BEGIN
Select t. bz_name into zname from t_banzu t where t. BZ_ID = zid;
RETURN zname;
END Get_BZ_name_BY_ID;
Create or replace FUNCTION Get_JS_name_BY_ID
(
Zid in number
)
RETURN nvarchar2
Zname nvarchar2 (100 );
BEGIN
Select t. js_name into zname from T_juese t where t. js_ID = zid;
RETURN zname;
END Get_JS_name_BY_ID;
Create or replace FUNCTION Get_Z_name_BY_ID
(
Zid in number
)
RETURN nvarchar2
Zname nvarchar2 (100 );
BEGIN
Select t. Z_name into zname from T_zhan t where t. Z_ID = zid;
RETURN zname;
END Get_Z_name_BY_ID;
Final query statement:
Select YH_ID, YH_USERNAME, YH_MIMA, Get_Z_NAME_BY_ID (t. FK_Z_ID) Z_name, Get_BZ_name_BY_ID (t. FK_bz_ID) bz_name, Get_BM_name_BY_ID (t. FK_BM_ID) js_name, Get_JS_name_BY_ID (t. FK_JS_ID) js_name, YH_NAME from t_yonghu t