You are correct, I mangled the actual query. What I meant to type was SELECT book_author, GROUP_CONCAT(book_title) AS book_title FROM books WHERE book_title LIKE "<something>" GROUP BY book_author;
The key question was about the use of the true name of a column in the WHERE clause while using an alias of the same name in the list of columns to be retrieved. Apparently this is the way SQL defines it to work. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 > -----Original Message----- > From: Felix Geerinckx [mailto:[EMAIL PROTECTED] > Sent: Wednesday, January 24, 2007 3:21 AM > To: mysql@lists.mysql.com > Subject: Re: Alias a function result? > > [EMAIL PROTECTED] ("Jerry Schwartz") wrote in > news:[EMAIL PROTECTED]: > > > SELECT book_author, GROUP_CONCAT(book_title) AS book_title GROUP BY > > book_author WHERE book_title LIKE "<something>"; > > > > This actually seems to work, but it makes me ill to look at it. > > I doubt this works: there is no FROM clause, and the WHERE > and GROUP BY > clauses are in the wrong order. > > The following will work: > > SELECT book_author, GROUP_CONCAT(book_title) AS book_title > FROM foo > WHERE book_title LIKE '<SOMETHING>' > GROUP BY book_author > > but the book_title in the WHERE clause is *not* the alias but the > individual column. Results of an aggregate function are *never* > available in a WHERE clause. > > You need a HAVING clause. > > -- > felix > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]