使用者:

UserID | UserName
--------------
1        Jack
2        Evelin


店:

ShopID | ShopName | ShopUserID
-------------------------------
1        Prague     1
2        Berlin     2


可以获取自动更新表:

ShopID | ShopName | ShopUserID
-------------------------------
1        Prague     Jack
2        Berlin     Evelin


我可以使用扳机吗?

谢谢!

最佳答案

请使用Join,请尝试以下查询:

Select s.shopID,s.ShopName,u.UserName from Shop as s Left Join Users as u on s.ShopUserID = u.UserID


输出将如下所示:

ShopID | ShopName | UserName
-------------------------------
1        Prague     Jack
2        Berlin     Evelin

08-07 22:19