I'm trying to do a SELECT query in SQL in Java (Netbeans) using Access as SGBD but when it seems that the comma (",") that you can put between tables in Access doesn't work on Java ?
What am I doing wrong?
Thanks to @teppic for his answer but doesn't work much`
However, I still have the problem: it says syntax error in FROM. What is really strange is that the query works well in Access, and other (simpler) queries were correctly implemented in the Java script. I did not found doc on that in the books I bought or even on the Net because it's often with less tables ! Thank you in advance –
PreparedStatement ps = cnx.prepareStatement("SELECT Client.Nom , Facture.Date_Achat , Client.Prénom , Facture.N°Fac , SUM(Contient1.Quantité1*PrixAchatMonture)AS Somme"+
"FROM Facture , Client , Contient1 , Monture"+
"ON Facture.N°Client=Client.N°Client AND Facture.N°Fac=Contient1.N°Fac AND Contient1.IDM=Monture.IDM "+
"WHERE Client.Nom =? AND Client.Prénom=?"+
"GROUP BY Client.Nom, Facture.Date_Achat, Client.Prénom, Facture.N°Fac",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
// ! au sens de la jointure pour l'affichage
[Microsoft][Pilote ODBC Microsoft Access] In SELECT instruction,reserved word or missing argument or incorrect punctuation
Update
I tried adding the spaces to the end of each string fragment but I still get an error
PreparedStatement ps = cnx.prepareStatement("SELECT Client.Nom , Facture.Date_Achat , Client.Prénom , Facture.N°Fac , SUM(Contient1.Quantité1 * Monture.PrixAchatMonture) AS Somme "+ "FROM Facture "+ "INNER JOIN Client ON Facture.N°Client=Client.N°Client "+ "INNER JOIN Contient1 ON Facture.N°Fac=Contient1.N°Fac "+ "INNER JOIN Monture ON Contient1.IDM=Monture.IDM "+"WHERE Client.Nom =? AND Client.Prénom=? "+ "GROUP BY Client.Nom, Facture.Date_Achat, Client.Prénom, Facture.N°Fac ",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);