我需要你帮忙联络三张桌子。
我想用java来启发这段代码。

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"))));


             }
        }

我只知道现在要加入两个表
Select IdOrg, A.CodeA
from collabo A, album C
where A.CodeA = C.CodeA order by 1

最佳答案

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

关于mysql - 带3个表的SQL请求,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50620740/

10-10 23:39