Joining Strings
SQL>
SQL>
SQL> CREATE TABLE emp (
2 empID INT NOT NULL PRIMARY KEY,
3 CourseID INT NOT NULL,
4 ProfessorID INT NOT NULL,
5 RoomID INT NOT NULL,
6 Time VARCHAR(50));
Table created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (1,1,1,6,'Mon 09:00-11:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (2,2,1,5,'Mon 11:00-12:00, Thu 09:00-11:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (3,3,2,3,'Mon 14:00-16:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (4,4,3,2,'Tue 10:00-12:00, Thu 14:00-15:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (5,5,2,9,'Tue 14:00-16:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (6,6,3,2,'Tue 16:00-17:00, Thu 15:00-17:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (7,7,4,3,'Wed 09:00-11:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (8,8,5,8,'Wed 11:00-13:00, Fri 09:00-11:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (9,9,1,5,'Fri 11:00-13:00');
1 row created.
SQL> INSERT INTO emp (empID,CourseID,ProfessorID,RoomID,Time) VALUES (10,10,6,9,'Fri 14:00-16:00');
1 row created.
SQL>
SQL> SELECT empID,Time || ', Room ' || RoomID AS empDetails
2 FROM emp;
EMPID
----------
EMPDETAILS
--------------------------------------------------------------------------------
1
Mon 09:00-11:00, Room 6
2
Mon 11:00-12:00, Thu 09:00-11:00, Room 5
3
Mon 14:00-16:00, Room 3
4
Tue 10:00-12:00, Thu 14:00-15:00, Room 2
5
Tue 14:00-16:00, Room 9
6
Tue 16:00-17:00, Thu 15:00-17:00, Room 2
7
Wed 09:00-11:00, Room 3
8
Wed 11:00-13:00, Fri 09:00-11:00, Room 8
9
Fri 11:00-13:00, Room 5
10
Fri 14:00-16:00, Room 9
10 rows selected.
SQL>
SQL>
SQL> drop table emp;
Table dropped.
Related examples in the same category