Click to See Complete Forum and Search --> : sql srv column alias.... help


art
01-05-2001, 10:00 AM
Hi, i have a few question about the SQL of sql server 7.0

I whant to use column alias, here a complete exemple of what i have in mind
:



select exas_no , cours_titre from exaset,cours where exas_nocours=cours_no


I add a column :

select exas_no ,exas_nocours , cours_titre from exaset,cours where exas_nocours=cours_no


I add an alias to this column L

select exas_no ,exas_nocours as MyNo , cours_titre from exaset,cours where
exas_nocours=cours_no

Until now everything work correctly. But when i try to re-use that alias...
boom


select exas_no ,exas_nocours as MyNo , cours_titre from exaset,cours where
MyNo=cours_no



here the error :

Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'MyNo'.

Can someone help me on this matter please ?

Daniel Reber
01-05-2001, 10:41 AM
In you where clause I believe that you can't use the alias. You need to use
the column name.

Daniel Reber, MCP

art <artois_uo@hotmail.com> wrote in message
news:3a55e198$1@news.devx.com...


Hi, i have a few question about the SQL of sql server 7.0

I whant to use column alias, here a complete exemple of what i have in mind
:



select exas_no , cours_titre from exaset,cours where exas_nocours=cours_no


I add a column :

select exas_no ,exas_nocours , cours_titre from exaset,cours where
exas_nocours=cours_no


I add an alias to this column L

select exas_no ,exas_nocours as MyNo , cours_titre from exaset,cours where
exas_nocours=cours_no

Until now everything work correctly. But when i try to re-use that alias...
boom


select exas_no ,exas_nocours as MyNo , cours_titre from exaset,cours where
MyNo=cours_no



here the error :

Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'MyNo'.

Can someone help me on this matter please ?