我是sql新手,所以我需要幫助理解這一點。我有3個表格: -使用軟件包和光標連接三張表
表1: - 員工編號。 員工姓名 person_id
表2: - 聯繫號碼: PERSON_ID
表3: - 地址 PERSON_ID
我試圖使一包,並使用一個過程來定義一個遊標。現在我想從使用連接的表中顯示聯繫人號碼,地址和emp號碼。我已經應用了連接條件,但無法理解如何顯示結果。
包體
create or replace package pacakge_name
as
procedure procedure_name
declare
cursor cur_name is select * from table1 join table2 on table1.person_id=table2.person_id join table 3 on table1.person_idd=table3.id;
var_curname cur_name%rowtype;
begin
open cur_name;
loop
fetch cur_name into var_curname
exit
when cur_name%NOTFOUND;
end loop;
close cur_name;
end;
您標記了這個mysql,sql-server和oracle,您使用的是什麼RDBMS? – Taryn
對不起。錯誤的標籤。我更正了它 –