PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > WHERE and 'AS' problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
WHERE and 'AS' problem

Réponse
 
LinkBack Outils de la discussion
Vieux 31/01/2008, 10h29   #1
Geoff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut WHERE and 'AS' problem

SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
test_equipment_cal_days DAY ) AS test_equipment_expire_date
FROM `test_equipment`
WHERE test_equipment_expire_date < '2008-01-31'

#1054 - Unknown column 'test_equipment_expire_date' in 'where clause'

so, i simply can't do that ???
how am i supposed to do such a thing ?
  Réponse avec citation
Vieux 31/01/2008, 10h42   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WHERE and 'AS' problem

On 31 Jan, 10:29, Geoff <foooooo...@hotmail.com> wrote:
> SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
> test_equipment_cal_days DAY ) AS test_equipment_expire_date
> FROM `test_equipment`
> WHERE test_equipment_expire_date < '2008-01-31'
>
> #1054 - Unknown column 'test_equipment_expire_date' in 'where clause'
>
> so, i simply can't do that ???
> how am i supposed to do such a thing ?


Put it in the HAVING clause instead
  Réponse avec citation
Vieux 31/01/2008, 11h13   #3
Geoff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WHERE and 'AS' problem

Captain Paralytic wrote:
> On 31 Jan, 10:29, Geoff <foooooo...@hotmail.com> wrote:
>> SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
>> test_equipment_cal_days DAY ) AS test_equipment_expire_date
>> FROM `test_equipment`
>> WHERE test_equipment_expire_date < '2008-01-31'
>>
>> #1054 - Unknown column 'test_equipment_expire_date' in 'where clause'
>>
>> so, i simply can't do that ???
>> how am i supposed to do such a thing ?

>
> Put it in the HAVING clause instead


nice one

was the first thing that came to mind
i though you used that with group by only though

got it working
  Réponse avec citation
Vieux 31/01/2008, 11h31   #4
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WHERE and 'AS' problem

On 31 Jan, 11:13, Geoff <foooooo...@hotmail.com> wrote:
> Captain Paralytic wrote:
> > On 31 Jan, 10:29, Geoff <foooooo...@hotmail.com> wrote:
> >> SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
> >> test_equipment_cal_days DAY ) AS test_equipment_expire_date
> >> FROM `test_equipment`
> >> WHERE test_equipment_expire_date < '2008-01-31'

>
> >> #1054 - Unknown column 'test_equipment_expire_date' in 'where clause'

>
> >> so, i simply can't do that ???
> >> how am i supposed to do such a thing ?

>
> > Put it in the HAVING clause instead

>
> nice one
>
> was the first thing that came to mind
> i though you used that with group by only though
>
> got it working

There's a paragraph about MySQL's particular implementation of HAVING
on this page:

http://dev.mysql.com/doc/refman/5.0/en/select.html
  Réponse avec citation
Vieux 31/01/2008, 12h54   #5
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WHERE and 'AS' problem

Geoff wrote:
> Captain Paralytic wrote:
>> On 31 Jan, 10:29, Geoff <foooooo...@hotmail.com> wrote:
>>> SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
>>> test_equipment_cal_days DAY ) AS test_equipment_expire_date
>>> FROM `test_equipment`
>>> WHERE test_equipment_expire_date < '2008-01-31'
>>>
>>> #1054 - Unknown column 'test_equipment_expire_date' in 'where clause'
>>>
>>> so, i simply can't do that ???
>>> how am i supposed to do such a thing ?

>>
>> Put it in the HAVING clause instead

>
> nice one
>
> was the first thing that came to mind
> i though you used that with group by only though
>
> got it working
>


That is true in ANSI SQL. MySQL extends that functionality.

Personally, I wish ANSI would pick up on MySQL's way of doing things. I
see no logical reason for the restriction, and the syntax can be very handy.

Otherwise you have to repeat the entire calculated expression in the
WHERE clause. A good optimizer should recognize that, but who knows?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 31/01/2008, 13h01   #6
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: WHERE and 'AS' problem


"Jerry Stuckle" <jstucklex@attglobal.net> schreef in bericht
news:eOednZcnMt7jWDzanZ2dnUVZ_ournZ2d@comcast.com. ..
> Geoff wrote:
>> Captain Paralytic wrote:
>>> On 31 Jan, 10:29, Geoff <foooooo...@hotmail.com> wrote:
>>>> SELECT * , DATE_ADD( test_equipment_cal_date, INTERVAL
>>>> test_equipment_cal_days DAY ) AS test_equipment_expire_date
>>>> FROM `test_equipment`
>>>> WHERE test_equipment_expire_date < '2008-01-31'
>>>>
>>>> #1054 - Unknown column 'test_equipment_expire_date' in 'where clause'
>>>>
>>>> so, i simply can't do that ???
>>>> how am i supposed to do such a thing ?
>>>
>>> Put it in the HAVING clause instead

>>
>> nice one
>>
>> was the first thing that came to mind
>> i though you used that with group by only though
>>
>> got it working
>>

>
> That is true in ANSI SQL. MySQL extends that functionality.
>
> Personally, I wish ANSI would pick up on MySQL's way of doing things. I
> see no logical reason for the restriction, and the syntax can be very
> handy.
>
> Otherwise you have to repeat the entire calculated expression in the WHERE
> clause. A good optimizer should recognize that, but who knows?
>


the disadvantage of some people writing

SELECT name FROM persons HAVING name='Santa';

will stop this from becoming ANSI, i guess.....



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h29.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14117 seconds with 14 queries