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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine field names in query 1

Status
Not open for further replies.

oaklanders

Technical User
Dec 9, 2007
38
In my Oracle 9i I tried this and it gave me back an error saying fullname is invalid.
Code:
select firstname || ' ' || secondname as fullname where fullname like '%Jo%'

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

Please advise how I can get it working the first attempt working?
 
Sorry my error on examples:
Code:
select firstname || ' ' || secondname as fullname from myTable where fullname like '%Jo%'


select firstname || ' ' || secondname from myTable where firstname || ' ' || secondname like '%Jo%'
 
I don't think you can use the alias of a concatenation in a where clause...this would work though

select firstname || ' ' || secondname as fullname from myTable where firstname || ' ' || secondname like '%Jo%

-- Jason
"It's Just Ones and Zeros
 
You would have to put the concatenation into a subquery:
Code:
SELECT fullname
FROM (SELECT firstname || ' ' || secondname as fullname 
      FROM yourtable) 
WHERE fullname like '%Jo%';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top