Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Refer to Field

Author  Topic 

argaz
Starting Member

8 Posts

Posted - 2006-07-19 : 06:58:36
Hello,

I want to make the query :

SELECT DISTINCT articles.*, cstr([ArticleCats].[CatID]) AS ID1
FROM articles, ArticleCats
WHERE [Articles].[FieldCategory]=ID1;

it doesn't recognize the ID1 Field that I created at the beginning of the query.

What is the problem?

Thank you,
Argaz

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-19 : 07:00:47
you can't reference to a column alias in the where clause. You have to use the actual column name.


KH

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-07-19 : 07:01:39
try this

SELECT DISTINCT articles.*, cstr([ArticleCats].[CatID]) AS ID1
FROM articles, ArticleCats
WHERE [Articles].[FieldCategory]=cstr([ArticleCats].[CatID]) ;


EDIT:

Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

argaz
Starting Member

8 Posts

Posted - 2006-07-19 : 07:04:20
Thank you
Go to Top of Page
   

- Advertisement -