MySQL - Using an alias in a subquery with WHERE clause
        Posted  
        
            by gaoshan88
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by gaoshan88
        
        
        
        Published on 2010-04-19T20:19:03Z
        Indexed on 
            2010/04/19
            20:23 UTC
        
        
        Read the original article
        Hit count: 344
        
mysql
|mysql-query
I have a feeling I am completely borking this MySQL query but I'll ask anyway. I am wondering why I get the warning Unknown column 'FOO', and how I can get this query to work properly, in 'where clause' when I run the following:
SELECT
sample_id as FOO
FROM
tbl_test
WHERE
sample_id = 521 AND sample_id IN (
Select
sample_id
FROM
tbl_test
WHERE
sample_id = FOO
GROUP BY sample_id
)
        © Stack Overflow or respective owner