How can I create a view that merges different all columns from two different tables.
CREATE VIEW listView
AS
SELECT * FROM tab1 h LEFT JOIN tab2 b
ON h.tID=b.tID
WHERE value = 0
this give me the error:
Duplicate column name 'tID'
Is there a way to join the two tables without listing all the values to select?
解决方案
The two tables contains columns tID. In order to compile the VIEW, you need to create an alias on that column or just specify one tid and table where it will come from.
One solution:
SELECT h.TID, -- and not specifying b.TID
FROM tab1 h LEFT JOIN tab2 b ON h.tID=b.tID
Another solution: supply an alias,
SELECT h.TID as H_TID,
b.TID as B_TID
FROM tab1 h LEFT JOIN tab2 b ON h.tID=b.tID