I am trying to join TABLE_1 and TABLE_2, I need to use every one of these fields in my HTML table. I am getting an error about my FROM clause, but I believe there are more errors involved.
我正在尝试连接TABLE_1和TABLE_2,我需要在我的HTML表中使用这些字段中的每一个。我从子句中得到一个错误,但是我相信会有更多的错误。
"SELECT "
+ "TABLE_1.id, "
+ "TABLE_1.date, "
+ "TABLE_1.location, "
+ "TABLE_1.name, "
+ "TABLE_1.status "
+ "TABLE_2.date, "
+ "TABLE_2.location, "
+ "TABLE_2.name, "
+ "TABLE_2.type "
+ "FROM SCHEMA_1.TABLE_1 JOIN SCHEMA_1.TABLE_2 "
+ "WHERE TABLE_1.id = TABLE_2.id "
+ "AND add_user = ?");
3 个解决方案
#1
1
Try this, instead:
试试这个,而不是:
"SELECT "
+ "TABLE_1.id, "
+ "TABLE_1.date, "
+ "TABLE_1.location, "
+ "TABLE_1.name, "
+ "TABLE_1.status "
+ "TABLE_2.date, "
+ "TABLE_2.location, "
+ "TABLE_2.name, "
+ "TABLE_2.type "
+ "FROM "
+ " SCHEMA_1.TABLE_1 JOIN SCHEMA_1.TABLE_2 "
+ " ON TABLE_1.ID = TABLE_2.ID"
+ "WHERE add_user = ?");
#2
3
Change the WHERE TABLE_1.id = TABLE_2.id AND add_user = ?
for ON TABLE_1.id = TABLE_2.id WHERE add_user = ?
改变TABLE_1的地方。id = TABLE_2。id和add_user = ?在TABLE_1。id = TABLE_2。add_user = ?
#3
0
Join the tables by ON not where
不要在什么地方加入表格。
http://www.w3schools.com/sql/sql_join_inner.asp
http://www.w3schools.com/sql/sql_join_inner.asp
#1
1
Try this, instead:
试试这个,而不是:
"SELECT "
+ "TABLE_1.id, "
+ "TABLE_1.date, "
+ "TABLE_1.location, "
+ "TABLE_1.name, "
+ "TABLE_1.status "
+ "TABLE_2.date, "
+ "TABLE_2.location, "
+ "TABLE_2.name, "
+ "TABLE_2.type "
+ "FROM "
+ " SCHEMA_1.TABLE_1 JOIN SCHEMA_1.TABLE_2 "
+ " ON TABLE_1.ID = TABLE_2.ID"
+ "WHERE add_user = ?");
#2
3
Change the WHERE TABLE_1.id = TABLE_2.id AND add_user = ?
for ON TABLE_1.id = TABLE_2.id WHERE add_user = ?
改变TABLE_1的地方。id = TABLE_2。id和add_user = ?在TABLE_1。id = TABLE_2。add_user = ?
#3
0
Join the tables by ON not where
不要在什么地方加入表格。
http://www.w3schools.com/sql/sql_join_inner.asp
http://www.w3schools.com/sql/sql_join_inner.asp