2016-04-02 68 views

回答

0

好了,試試這個視圖查詢:

CREATE VIEW your_view_name AS 

SELECT * FROM refferal_benifits t1 INNER JOIN puja_order_details t2 
ON t1.puja_order_id = t2.puja_order_id 
INNER JOIN pujas t3 
ON t2.puja_id = t3.puja_id 
WHERE t1.puja_order_id = your_id_that_you_want 
0

要建立由三個表「訂單」,「客戶」和「藥」有以下條件的視圖 -

「一'和'b'和'c'是'訂單'和'客戶'和'代理'表的別名,

2.'orders'和'customer'表的'cust_code'必須相同,

「訂單」的「agent_code」和「代理」表必須是相同的,

下面的SQL語句可以使用:

CREATE VIEW ordersview 
AS SELECT ord_num, ord_amount, a.agent_code, 
agent_name, cust_name 
FROM orders a, customer b, agents c 
WHERE a.cust_code = b.cust_code 
AND a.agent_code = c.agent_code; 
相關問題