简体   繁体   中英

MySql Subqueries not returning a result

I'm trying to get my project to work remotely. I have everything working perfectly on my local machine but on my remote machine some of my webpages are not displaying the results from certain servlets. I know this is the case because my callback function is never called in the front end which means something is wrong with the back end.

This only occurs when my servlets are sending queries that have subqueries contained in them. I know that this is the case from checking the mysql logs. My servlet is trying to send two queries that have subqueries in them but when I check the mysql log it only received the first subquery.
The second query is never recorded in the logs. I then tried to see if I can manually run queries with subqueries in mysql via the terminal. I tried queries such as

1)

SELECT stars.id, stars.name 
FROM stars 
WHERE stars.id IN (SELECT stars_in_movies.starId FROM stars_in_movies, movies WHERE movies.id = 'tt0145487' AND stars_in_movies.movieId = movies.id)

Even simpler ones such as

2)

SELECT movies.title 
FROM movies 
WHERE movies.title in (select movies.title from movies where movies.title = 'Spider-Man').

In both cases I am not receiving a result from MySql. I am running these queries on Ubuntu.

Just use joins.

SELECT A.id, A.name 
FROM stars A JOIN stars_in_movies B 
ON A.id=B.starId AND B.movieId = 'tt0145487';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM