Stored procedures 用于从多个表中提取数据的存储过程

Stored procedures 用于从多个表中提取数据的存储过程,stored-procedures,Stored Procedures,我有这样的存储过程 Select k.HBarcode, m.make,t.plateno ,v.vtype ,l.locname,mdl.model,c.Colname from transaction_tbl t, KHanger_tbl k, make_tbl m, vtype_tbl v, Location_tbl l, Model_tbl mdl, Color_tbl C where t.t

我有这样的存储过程

Select k.HBarcode, m.make,t.plateno ,v.vtype ,l.locname,mdl.model,c.Colname 
from   transaction_tbl t,
       KHanger_tbl k,
       make_tbl m,
       vtype_tbl v,
       Location_tbl l,
       Model_tbl mdl,
       Color_tbl C  
 where t.tbarcode=@carid and 
       t.mkid=m.mkid and 
       v.vtid=t.vtid and 
       t.locid=l.locid and 
       mdl.mdlid=t.mdlid and 
       t.colid=c.colid and 
       t.transactID=k.transactID
执行此命令时,我将获得输出

HBarcode     make     plateno    vtype   locname          model        Colname
34           BMW      44554      Normal  Fashion Avenue   520          Red
我还有两个表,从事务表中我可以得到transaction ID(例如:t.transaction ID),然后我可以得到相应的 tid来自“KHanger_tbl”,然后我想显示来自“Terminal”表的相应tid的唯一名称

1-KHanger_tbl

transactid                              HBarcode                tid
--------------------------------------- ----------------------------------
19                                      34                      7
22                                      002                     5
21                                      1                       7
23                                      200005                   6
2-端子

tid         UniqueName
----------- --------------------------------------------------
5           Key Room-1
6           Podium -1
7           Key Room - 2
预期产量
所以我如何为这个编写存储过程,如果有人知道,请帮我写一些类似的东西

Select  term.UniqueName , 
   k.HBarcode, m.make,t.plateno ,v.vtype ,l.locname,mdl.model,c.Colname 
from transaction_tbl t,
     KHanger_tbl k,
     make_tbl m,
     vtype_tbl v,
     Location_tbl l,
     Model_tbl mdl,
     Color_tbl C  
     ,
     Terminals_tbl Term

where t.tbarcode=@carid and 
      t.mkid=m.mkid and 
      v.vtid=t.vtid and 
      t.locid=l.locid and 
      mdl.mdlid=t.mdlid and 
      t.colid=c.colid and 
      t.transactID=k.transactID 
      and
      term.tid = t.transactID
Select  term.UniqueName , 
   k.HBarcode, m.make,t.plateno ,v.vtype ,l.locname,mdl.model,c.Colname 
from transaction_tbl t,
     KHanger_tbl k,
     make_tbl m,
     vtype_tbl v,
     Location_tbl l,
     Model_tbl mdl,
     Color_tbl C  
     ,
     Terminals_tbl Term

where t.tbarcode=@carid and 
      t.mkid=m.mkid and 
      v.vtid=t.vtid and 
      t.locid=l.locid and 
      mdl.mdlid=t.mdlid and 
      t.colid=c.colid and 
      t.transactID=k.transactID 
      and
      term.tid = t.transactID