Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referring to a Computed column in WHERE clause

Status
Not open for further replies.

rclawson

Programmer
May 13, 2005
7
US
Is it possible to do something like this?

Code:
select (BillPrefix + ' ' + BillNumber) as Bill
from Bills
where Bill like 'HF 3%'
I get an error when I execute this, but I want to be able to do a partial match over both columns. Is this something that could be done with a dynamic view (i.e., in the FROM clause). The user would enter text such as "HF 3".

Any thoughts?

RC
 
try
select (BillPrefix + ' ' + BillNumber) as Bill
from Bills
where (BillPrefix + ' ' + BillNumber) like 'HF 3%'

Note that if BillNumber is numeric then you need to use cast(BillNumber as char) instead

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks. That looks like that will do the trick.

RC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top