我已經做了兩個Table
(Quotation1
和Quotation2
)和它具有以下Columns
像:如何連接兩個表和第三個表顯示結果
CREATE TABLE Quotation1 (
Q_No INTEGER (10),
Date DATE,
C_Code VARCHAR (45),
C_Name VARCHAR (45),
C_Contact VARCHAR (45),
G_Tot VARCHAR (45),
Remarks VARCHAR (250)
);
CREATE TABLE Quotation2 (
Q_No VARCHAR (45),
P_Code VARCHAR (45),
P_Name VARCHAR (45),
Price VARCHAR (45),
Qnty INTEGER (10),
Amt VARCHAR (45),
Discount_Per INTEGER (10),
Discount INTEGER (10),
VAT_Per INTEGER (10),
VAT INTEGER (10),
Tot_Amt VARCHAR (45)
);
我不得不Joins
這兩個Table
並顯示其Result
在Third Table
Quotation
其中有以下Columns
像:
CREATE TABLE Quotation (
Q_No INT (10) PRIMARY KEY
NOT NULL,
Date DATE,
C_Code VARCHAR (45) REFERENCES CustomerInfo (C_Code) ON DELETE NO ACTION
ON UPDATE NO ACTION
MATCH SIMPLE NOT DEFERRABLE INITIALLY DEFERRED,
C_Name VARCHAR (45),
C_Contact VARCHAR (45),
Remarks VARCHAR (45),
P_Code VARCHAR (45) REFERENCES ProductInfo (P_Code) ON DELETE NO ACTION
ON UPDATE NO ACTION
MATCH SIMPLE NOT DEFERRABLE INITIALLY DEFERRED,
P_Name VARCHAR (45),
Price VARCHAR (45),
Qnty INTEGER (10),
Amount VARCHAR (45),
Discount_Per INTEGER (10),
Discount INTEGER (10),
VAT_Per INTEGER (10),
VAT INTEGER (10),
Tot_Amt VARCHAR (45),
G_Tot VARCHAR (45)
)
WITHOUT ROWID;
我已經申請繼Query
一樣:
INSERT INTO Quotation (Q_No,Date,C_Code,C_Name,C_Contact,Remarks,P_Code,P_Name,Price,Qnty,Amount,Discount_Per,Discount,VAT_Per,VAT,Tot_Amt,G_Tot)
SELECT Quotation2.Q_No,
Quotation1.Date,
Quotation1.C_Code,
Quotation1.C_Name,
Quotation1.C_Contact,
Quotation1.Remarks,
Quotation2.P_Code,
Quotation2.P_Name,
Quotation2.Price,
Quotation2.Qnty,
Quotation2.Amt,
Quotation2.Discount_Per,
Quotation2.Discount,
Quotation2.VAT_Per,
Quotation2.VAT,
Quotation2.Tot_Amt,
Quotation1.G_Tot
FROM Quotation1,
Quotation2
INNER JOIN Quotation ON Quotation1.Q_No=Quotation2.Q_No;
它給人的關注Result
我愛:[02:16:23] Query finished in 0.010 second(s).
但不顯示任何Data
甚至沒有Column Name
請幫助。
對於初學者..你不應該使用'Date'命名一個字段。這只是一個壞習慣,因爲它是MySQL使用的保留術語。我懷疑它會影響你的查詢,只是指出一個觀察... – Zak