Jump to content

problem with alias in subquery


attaboy

Recommended Posts

This doesn't work on my system

mysql 5.5.16

ERROR 1054(42s22): unknown column 'c' in 'where clause'

 

SELECT Code c, Name
FROM Country
WHERE Continent = 'Europe'
AND EXISTS (SELECT *
      FROM CountryLanguage
      WHERE CountryCode = c AND Language = 'Spanish');

 

The error message states there's an unknown column 'c' in the where clause.

can't subqueries handle aliases?

Link to comment
https://forums.phpfreaks.com/topic/262162-problem-with-alias-in-subquery/
Share on other sites

But the whole idea is to find only countries in Europe where Spanish is spoken.

The original code I posted here is copied from the sample code of my textbook which is MySQL 5.0 Study Guide from MySQL Press

I'm trying to determine if the book is wrong and you can't  access an alias defined in an outer query from an inner query or if just I can't do that.  Except the alias issue the query works fine. If in the inner query I replace the 'c' with 'country.Code' it works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.