且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL创建连接两个完整表的视图

更新时间:2023-01-20 08:08:55

两个表都包含列tID.为了编译VIEW,您需要在该列上创建一个别名,或仅指定一个tid和一个表,该别名将来自何处.

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.

一种解决方案:

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