此 SQL 查询:
String query =
"select userclient.username from twitter_content.userclient " +
"where userclient.userid = " +
"(select follower.followerid from twitter_content.follower where " +
"follower.followerid = userclient.userid and follower.userid = " +
userID +
")";
在控制台上打印:
select userclient.username from twitter_content.userclient where userclient.userid = (select follower.followerid from twitter_content.follower where follower.followerid = userclient.userid and follower.userid = 562570958)
此查询在直接在 MySQL 脚本中运行时有效,但在通过在 Eclipse 中运行的 Java 程序执行时无效。在 Eclipse 中运行时出现此异常:
java.sql.SQLException: Column 'followerid' not found.
我已经有了表 Follower,其中包含列followerid
。我该如何解决这个问题?
编辑:
UserClient 表有 2 列:用户 ID 和用户名。
Follower 表有 3 列:rowno、userid 和 followerid。