Question: SQLite query cannot inner join tables in Java, but the query works on SQLite Manager. Query results on SQLite Manager: Select t1.Table1Test1 AS T1T1, t2.Table2Test1

SQLite query cannot inner join tables in Java, but the query works on SQLite Manager.

Query results on SQLite Manager:

Select t1.Table1Test1 AS T1T1, t2.Table2Test1 AS T2T1, t3.Table3Test1 AS T3T1, t4.Table4Test1 AS T4T1 From Table1 t1 INNER JOIN Table2 t2 ON t1.Table1PK = t2.Table1PK INNER JOIN Table3 t3 ON t2.Table2PK = t3.Table2PK INNER JOIN Table4 t4 ON t3.Table3PK = t4.Table3PK WHERE T1T1 = "table1test1"

SQLite query cannot inner join tables in Java, but the query works

Query Results on Java, it gives an error when inner joining tables in Java (The query is the same on SQLite and Java, but different results):

on SQLite Manager. Query results on SQLite Manager: Select t1.Table1Test1 AS T1T1,t2.Table2Test1 AS T2T1, t3.Table3Test1 AS T3T1, t4.Table4Test1 AS T4T1 From Table1 t1

When I don't inner join tables in Java, the query works:

final String sql = "Select t1.Table1Test1 AS T1T1,t1.Table1Test1 AS T2T1, t1.Table1Test1 AS T3T1,t1.Table1Test1 AS T4T1" + " FROM Table1 t1 WHERE t1.Table1Test1 = ?";

INNER JOIN Table2 t2 ON t1.Table1PK = t2.Table1PK INNER JOIN Table3 t3

Here is a link to Google Drive for the database, Create Table, Insert Value and Query files: https://drive.google.com/open?id=1vrWDtAh8qIkVECWT030IHNXJkN0Ctq9Y

Please look at the table I created and why query with inner join works on SQLite, but doesnt work when executing it in Java.

1 Select t1.Table1Testl AS T1T1, t2.Table2Testl AS T2T1, t3.Table3Test1 AS T3T1, t4.Table4Testl AS T4T1 2 From Table1 t1 INNER JOIN Table2 t2 ON t1Table 1 PK = t2Table 1 PK INNER JOIN Table3 t3 ON t2.Table2PK-t3,Table2 PK 4 INNER JOIN Table4 t4 ON t3.Table3PK t4.Table3PK wHERE T1T1 = 'table 1 test!' T1T1 T2T1 T3T1 T4T1 1 table1test1 table2test1 table3test1 table4test1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!