首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >包含3个表的SQL请求

包含3个表的SQL请求
EN

Stack Overflow用户
提问于 2018-05-31 17:16:31
回答 1查看 36关注 0票数 1

我需要你帮我处理三张桌子之间的联系。我想在java中激发这段代码的灵感。

代码语言:javascript
复制
ResultSet resu = ConnexionMySQL.getInstance().selectQuery (req);
        try {
            while (resu.next())
            {        
                myList.add (new Collabo(resu.getInt("IdOrg"), 
                             new Album(resu.getString("CodeA"), resu.getString("TitreA"), 
                             new Chanteur (resu.getInt("IdentC"),resu.getString("IdentC")),
                             resu.getDate("DateArrivee"))));


             }
        }

我只知道现在要连接两张桌子

代码语言:javascript
复制
Select IdOrg, A.CodeA
from collabo A, album C
where A.CodeA = C.CodeA order by 1 

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-31 17:34:38

代码语言:javascript
复制
SELECT c.IdOrg, a.CodeA, ch.NomC
FROM album a 
LEFT JOIN collabo c ON a.CodeA = c.CodeA
LEFT JOIN chanteur ch ON a.IdentC = ch.IdentC
ORDER BY a.CodeA 
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50620740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档