Link to home
Start Free TrialLog in
Avatar of barney75
barney75

asked on

Combining 2 columns as one ?

Hello

I am hoping that there is some way in SQL to combine the values of 2 columns into one in the ResultSet. Can you tell me if this is can be done?

Teachers

teacher       class
-------------------------
Mr Doyle     Math

Supervisors

supervisor     class
---------------------------
Mr Reid          Math


I want to display the following:

class              teachers
--------------------------------
Math              Mr Doyle, Mr Reid


Any suggestions?
Avatar of SjoerdvW
SjoerdvW
Flag of Netherlands image

SELECT dbo.Supervisors.class, RTRIM(dbo.Teachers.teacher) + ', ' + dbo.Supervisors.supervisor AS Teacher FROM dbo.Supervisors INNER JOIN dbo.Teachers ON dbo.Supervisors.class = dbo.Teachers.class
Avatar of Pratima
select T.class , T.teacher + ',' + s.supervisor as teachers
from supervisor S , Teachers T
Avatar of barney75
barney75

ASKER

On both of those - "ORA-01722 - invalid number".  I am using an oracle db by the way...
Don't know oracle, but since the error say's invalid number it probably aspected numbers in the columns. Try to replace the + with & 
ASKER CERTIFIED SOLUTION
Avatar of SjoerdvW
SjoerdvW
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you SjoerdvW, the || did the trick!