Home » SQL & PL/SQL » SQL & PL/SQL » Combine fields in query
Combine fields in query [message #302456] Mon, 25 February 2008 16:50 Go to next message
florida
Messages: 82
Registered: April 2006
Member
In my Oracle 9i I tried this with an alias and it gave me back an error saying fullname is invalid.
select firstname || ' ' || secondname as fullname where fullname like '%Jo%'


This works:
select firstname || ' ' || secondname where firstname || ' ' || secondname like '%Jo%'


Please advise how I can get it working with the alias attempt?


Re: Combine fields in query [message #302475 is a reply to message #302456] Mon, 25 February 2008 19:32 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
I don't know how the second one would work without a FROM clause. Make sure you paste real code next time.

You cannot reference aliases in the WHERE clause, but you may encapsulate the query in an inline view.
select fullname
from (
    select firstname || ' ' || secondname as fullname
    from tbl
)
where fullname like '%Jo%'


Ross Leishman
Re: Combine fields in query [message #302479 is a reply to message #302456] Mon, 25 February 2008 19:41 Go to previous message
florida
Messages: 82
Registered: April 2006
Member
Thanks for your help.
Sorry about the From error.
Previous Topic: Extract long Raw columns to file
Next Topic: HELP IN NOT LIKE / INSTEAD OF NOT LIKE
Goto Forum:
  


Current Time: Thu Dec 08 02:06:37 CST 2016

Total time taken to generate the page: 0.11644 seconds