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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.