0
SQL Question Using As Clause
Explorer
,
/t5/dreamweaver-discussions/sql-question-using-as-clause/td-p/172602
Jul 08, 2008
Jul 08, 2008
Copy link to clipboard
Copied
I using the AS clause to define 'myZip' as seen below, but am
unable to use the WHERE clause using the defined column. This is a
scaled down version of what I am trying to do but will sufice as an
example:
SELECT npp_users.ZIP as myZip
FROM users
WHERE myZip = `00010`
Anyone have any clues?
Thanks
SELECT npp_users.ZIP as myZip
FROM users
WHERE myZip = `00010`
Anyone have any clues?
Thanks
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/sql-question-using-as-clause/m-p/172603#M183413
Jul 08, 2008
Jul 08, 2008
Copy link to clipboard
Copied
VernMan wrote:
> I using the AS clause to define 'myZip' as seen below, but am unable to use the
> WHERE clause using the defined column. This is a scaled down version of what I
> am trying to do but will sufice as an example:
>
> SELECT npp_users.ZIP as myZip
> FROM users
> WHERE myZip = `00010`
>
> Anyone have any clues?
>
WHERE myZip = "00010"
Mick
> I using the AS clause to define 'myZip' as seen below, but am unable to use the
> WHERE clause using the defined column. This is a scaled down version of what I
> am trying to do but will sufice as an example:
>
> SELECT npp_users.ZIP as myZip
> FROM users
> WHERE myZip = `00010`
>
> Anyone have any clues?
>
WHERE myZip = "00010"
Mick
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/sql-question-using-as-clause/m-p/172604#M183414
Jul 08, 2008
Jul 08, 2008
Copy link to clipboard
Copied
.oO(Michael White)
>VernMan wrote:
>> I using the AS clause to define 'myZip' as seen below, but am unable to use the
>> WHERE clause using the defined column. This is a scaled down version of what I
>> am trying to do but will sufice as an example:
>>
>> SELECT npp_users.ZIP as myZip
>> FROM users
>> WHERE myZip = `00010`
>>
>> Anyone have any clues?
>>
>
>WHERE myZip = "00010"
Nope. The correct delimiter for strings in SQL is the single quote
(assuming that the ZIP code is stored as a string - as a numeric even
the single quotes would be wrong).
The problem here is that you can't use alias names in a WHERE clause.
You either have to use the same expression as in the SELECT part (here:
npp_users.ZIP) or a HAVING clause.
B.1.5.4. Problems with Column Aliases
http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html
Micha
>VernMan wrote:
>> I using the AS clause to define 'myZip' as seen below, but am unable to use the
>> WHERE clause using the defined column. This is a scaled down version of what I
>> am trying to do but will sufice as an example:
>>
>> SELECT npp_users.ZIP as myZip
>> FROM users
>> WHERE myZip = `00010`
>>
>> Anyone have any clues?
>>
>
>WHERE myZip = "00010"
Nope. The correct delimiter for strings in SQL is the single quote
(assuming that the ZIP code is stored as a string - as a numeric even
the single quotes would be wrong).
The problem here is that you can't use alias names in a WHERE clause.
You either have to use the same expression as in the SELECT part (here:
npp_users.ZIP) or a HAVING clause.
B.1.5.4. Problems with Column Aliases
http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html
Micha
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/sql-question-using-as-clause/m-p/172605#M183415
Jul 09, 2008
Jul 09, 2008
Copy link to clipboard
Copied
SELECT npp_users.ZIP [myZip]
FROM users
WHERE npp_users.ZIP = `00010`
"VernMan" <webforumsuser@macromedia.com> wrote in message
news:g50s5b$c52$1@forums.macromedia.com...
>I using the AS clause to define 'myZip' as seen below, but am unable to use
>the
> WHERE clause using the defined column. This is a scaled down version of
> what I
> am trying to do but will sufice as an example:
>
> SELECT npp_users.ZIP as myZip
> FROM users
> WHERE myZip = `00010`
>
> Anyone have any clues?
>
> Thanks
>
FROM users
WHERE npp_users.ZIP = `00010`
"VernMan" <webforumsuser@macromedia.com> wrote in message
news:g50s5b$c52$1@forums.macromedia.com...
>I using the AS clause to define 'myZip' as seen below, but am unable to use
>the
> WHERE clause using the defined column. This is a scaled down version of
> what I
> am trying to do but will sufice as an example:
>
> SELECT npp_users.ZIP as myZip
> FROM users
> WHERE myZip = `00010`
>
> Anyone have any clues?
>
> Thanks
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

