Why am I getting error 1054 for this query ? Is there a more efficient way to write this query?

夙愿已清 提交于 2020-07-23 06:45:30

问题


I am working with the sakila database and I need to write a query to find out all the films that are available in the country Canada.

SELECT FILM_ID AS Film_id, TITLE AS Title 
FROM FILM
WHERE COUNTRY IN ( SELECT COUNTRY
                   FROM COUNTRY 
                   INNER JOIN CITY USING (COUNTRY_ID)
                   INNER JOIN ADDRESS USING (CITY_ID)
                   INNER JOIN STORE USING (ADDRESS_ID)
                   INNER JOIN INVENTORY USING (STORE_ID)
                   INNER JOIN FILM USING (FILM_ID)
                   WHERE COUNTRY = 'Canada')
ORDER BY Title ; 

When I try to run the above-written query, I am getting an Error 1054, unknown column 'country' in 'IN/ALL/ANY' Subquery.

I tried rewriting the entire query to ensure that I'm not getting this error because of invisible garbage characters (I don't know what invisible garbage characters in queries are, I read a stack overflow answer for a similar type of an error) and even after that, it doesn't work.

Am I getting this error because of the numerous join clauses in the subquery or is that fine? Is there a more efficient way to write this query?

Please let me know what is wrong with this query and do tell what are invisible garbage characters in queries.

来源:https://stackoverflow.com/questions/62763449/why-am-i-getting-error-1054-for-this-query-is-there-a-more-efficient-way-to-wr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!