2011-09-02 67 views
0

我有3代表在我的數據庫,如下圖所示: -如何實現連接操作

(1) users_registration 
    - username 
    - email 
    - acode 

(2) vendor_registration 
    - vid 
    - vkey 
    - btype 
    - email 
    - pass 
    - bussname 
    - regdate 
    - url 
    - ownerfname 

(3) vorder 
    - ttime 
    - vid 
    - tid 
    - oid 
    - uid 
    - amount 
    - cardid 

的用戶名在users_registration表和uid在vorder表是一樣的。

我的代碼是迄今爲止: -

SELECT vo.ttime,vo.vid,vo.tid,vo.oid,vo.uid,vo.amount,vo.cardid, vr.bussname 
from vorder vo 
INNER JOIN vendor_registration vr ON vo.vid=vr.vid 
where uid='".$name_array[$z]."' 
order by ttime desc"; 

應用此代碼我的網頁看起來像 後[在這裏輸入的形象描述] [1]

其實,我想告訴我的bussname!在VID

e451ffc8-db29-4c08-ac67-0177aec6e2ab as shown in image vendorname, 

回答

1
SELECT vo.ttime, vr.bussname, vo.tid, vo.oid, vo.uid, vo.amount, vo.cardid 
     FROM vorder vo 
INNER JOIN vendor_registration vr 
     ON vo.vid = vr.vid 
    WHERE uid = '".$name_array[$z]."' 
    ORDER BY ttime DESC 
的地方