PreparedStatement amovie = con.prepareStatement("INSERT INTO actor_movie(actor_ID, movie_ID)"+ "select actor_ID from actor" + "where actor.surname = 'Depp', select movie_ID from movie where movie.title LIKE 'Caribbean%'");
有人可以告诉我此查询出了什么问题吗?我挖了互联网,但找不到解决方法。
错误消息:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', select movie_ID from movie where title LIKE 'Caribbean%'' at line 1
答案 0 :(得分:0)
注意字符串之间需要连接的空格
var pauseToken = new PauseToken();
//Use pauseToken on all threads that consume a lot of CPU
Task.Run(async () => {
while (true) {
await Task.Delay(250); //run
pauseToken.Pause();
await Task.Delay(750); //pause
pauseToken.Resume();
}
});
答案 1 :(得分:0)
您有语法错误,因为您忘记了VALUES
,并在括号SELECT
中加上了括号。
更改为此:
PreparedStatement amovie = con.prepareStatement(
"INSERT INTO actor_movie(actor_ID, movie_ID) VALUES ((select actor_ID from actor where actor.surname = 'Depp'), (select movie_ID from movie where movie.title LIKE 'Caribbean%'))");