[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: select ... having bug?


Having works on the result table, not the source tables.
Since you did not select cnt, having can not examine it.

Maybe you ment 'where' instead of 'having' ?

\"Piotr Gapinski\" wrote:
> 
> small problems with query below...
> my fault?
> 
> mysql> desc poll_answer;
> +---------+-------------+------+-----+---------+-------+
> | Field   | Type        |Null  | Key | Default | Extra |
> +---------+-------------+------+-----+---------+-------+
> | poll_id | int(10)     |      |     | 0       |       |
> | cnt     | int(10)     |      |     | 0       |       |
> | answer  | varchar(60) |      |     |         |       |
> +---------+-------------+------+-----+---------+-------+
>  3 rows in set (0.00 sec)
> 
> mysql> select answer from poll_answer having cnt=1;
> ERROR 1054: Unknown column 'cnt' in 'having clause'
> 
> mysqladmin Ver 8.18 Distrib 3.23.35, for pc-linux-gnu on i686 -- Copyright
> (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
> This software comes with ABSOLUTELY NO WARRANTY.
> This is free software, and you are welcome to modify and redistribute it
> under the GPL license
> 
> Server version 3.23.35 Protocol version 10 Connection Localhost via UNIX
> socket UNIX socket /var/lib/mysql/mysql.sock Uptime:  3 days 10 hours 24
> min 20 sec
> 
> Threads: 1  Questions: 4192  Slow queries: 0  Opens: 116  Flush tables: 1
> Open tables: 23 Queries per second avg: 0.014
> 
> --
>   Piotr Gapinski mailto:news@xxxxxxxxxxxx
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <mysql-thread68797@xxxxxxxxxxxxxxx>
> To unsubscribe, e-mail <mysql-unsubscribe-gerald_clark=suppliersystems.com@xxxxxxxxxxxxxxx>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread68863@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



This mailing list archive is a service of Copilot Consulting.