Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 列 Table1:email1和email2。我需要通过连接其他表中的 FirstName 和 LastName 来获取全名,并且它与上述电子邮件字段相关联。但我需要确保,如果 email2 字段存在则获取关联的名称列,如果 email2 字段为空,则获取与 email1 关联的值。所以请告诉我如何使用 ifnull() 并进行内部连接?这是表结构:
Table1
表格1
表2
在此先感谢,克里希纳
SELECT COALESCE(CONCAT(c.FirstName, ' ', c.LastName), CONCAT(b.FirstName, ' ', b.LastName)) FullName FROM table1 a LEFT JOIN table2 b ON a.email1 = b.email LEFT JOIN table2 c ON a.email2 = c.email
要进一步了解有关联接的更多信息,请访问以下链接: