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
 General SQL Server Forums
 New to SQL Server Programming
 select +replace querry problem..

Author  Topic 

a4nsd
Starting Member

20 Posts

Posted - 2006-12-20 : 00:25:27
Hi.every one. I have a problem when I use this querry
select replace(Title,'.','')AS Title1, ID from tbl_Sim Where Title1 LIKE '%377%'

And here is my record
Title : 0988.613.775
ID : 2

and here is the error: Invalid column name 'Title1'.
Can any one show me how to run this querry, I want to TRIM the 'Title' before it can be compared with another condition
I am a beginner. Thanks alots!

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-12-20 : 00:53:07
select replace(Title,'.','')AS Title1, ID from tbl_Sim Where replace(Title,'.','') LIKE '%377%'

You can't refer to the aliased column in the where clause.

Duane.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-20 : 03:43:28

1 You can directly use alias name only at Order by caluse
2 Derived table is your friend
Select * from
(select replace(Title,'.','')AS Title1, ID from tbl_Sim)
T Where Title1 LIKE '%377%'



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -