2017-05-30 56 views
0

我要加入兩個表完全如何加入兩個表我

productbill 
BillID | TransactionID 
1  | 12344 
2  | 34353 

viewproduct 
sno|BillID|Productname|Rate|Quantity|Amount 
1 |1  |xyz  |12 |2  |24 

required output 
    BillID|TransactionID|Productname|Rate|Quantity|Amount 
    1 | 12344  |xyz  |12 |2  |24 

我的查詢是:

$joinview=mysql_query("select viewproduct.BillID,productbill.TransactionID,viewproduct.Productname,viewproduct.Rate,viewproduct.Quantity,viewproduct.Amount from viewproduct FULL OUTER JOIN productbill ON productbill.BillID=viewproduct.BillID"); 

請幫我在這

回答

0

SQL內連接的你需要什麼!

SQL INNER JOIN

查看示例代碼和演示數據庫。

SELECT productbill.BillID, productbill.TransactionID, viewproduct.Productname, viewproduct.Rate, viewproduct.Quantity, viewproduct.Amount 
FROM productbill 
INNER JOIN viewproduct ON productbill.BillID = viewproduct.BillID; 
0

正如Maasoud建議的那樣,您需要Inner Join。

查詢將

$joinview=mysql_query("SELECT productbill.billId as billId, productbill.TransactionID as TransactionID ,viewproduct.Productname as Productname, viewproduct.Rate as Rate, viewproduct.Quantity as Quantity, viewproduct.Amount as Amount FROM productbill AS productbill INNER JOIN viewproduct as viewproduct ON viewproduct.BillID = productbill.BillID");