[PerlChina] 有个SQL 查询,出错了。着急问一下结果

rorot yang.liana at gmail.com
Wed Dec 3 22:56:48 PST 2008


谢谢各位,只能这样了:)

2008/12/4 smallfish <smallfish at live.cn>

> 只能用
> SELECT (unix_timestamp(now()) - unix_timestamp(starttime)) as diff FROM
> `workers` WHERE (unix_timestamp(now()) - unix_timestamp(starttime)) < 900;
>
> where里是不能用前面as的名字
>
> --------------------------------------------------
> From: "Fayland Lam" <fayland at gmail.com>
> Sent: Thursday, December 04, 2008 2:44 PM
> To: <china-pm at pm.org>
> Subject: Re: [PerlChina] 有个SQL 查询,出错了。着急问一下结果
>
>
>  rorot wrote:
>>
>>> 不好意思,着急用。刚才在SQL IRC里没人回答。所以发这里,望有人解决一下。
>>>
>>> SELECT (unix_timestamp(now()) - unix_timestamp(starttime)) as diff
>>> FROM `workers` WHERE diff < 900;
>>>
>>
>> sounds like you want HAVING. you can't use SELECT result to be a WHERE.
>> it's not logic sane.
>>
>>
>>> 上面这条MySQL查询为什么出错??
>>>
>>> *MySQL said: *Documentation
>>> <http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html>
>>>
>>> | #1054 - Unknown column 'diff' in 'where clause' |
>>>
>>>
>>>
>>> rorot Dec/04/2008
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> China-pm mailing list
>>> China-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/china-pm
>>>
>>
>>
>> --
>> Fayland Lam // http://www.fayland.org/
>> Foorum based on Catalyst // http://www.foorumbbs.com/
>>
>> _______________________________________________
>> China-pm mailing list
>> China-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/china-pm
>>
>
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20081204/478a7818/attachment-0001.html>


More information about the China-pm mailing list