Two Laptop Bag*
The moose likes Oracle/OAS and the fly likes Creating a view combining two columns into one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Creating a view combining two columns into one" Watch "Creating a view combining two columns into one" New topic
Author

Creating a view combining two columns into one

Paul Kennerley
Greenhorn

Joined: Apr 24, 2005
Posts: 2
If I have two tables as shown below, could anyone tell me if and how its possible to create a view
that has only one column that contains the dbName values from both the tutor and student tables?

Thanks in advance

CREATE TABLE tutor
(
dbId INTEGER ,
dbName VARCHAR(20),
dbEmail VARCHAR(20),
dbPassword VARCHAR(8)NOT NULL
);



CREATE TABLE student
(
dbId INTEGER NOT NULL PRIMARY KEY,
dbName VARCHAR(20),
dbCourse VARCHAR(20),
dbPassword VARCHAR(8) NOT NULL,
dbPersonalTutorId INTEGER NOT NULL
);
Jon Egan
Ranch Hand

Joined: Mar 24, 2004
Posts: 83
Paul,

Look into using two queries combined with UNION.... and check into the difference between UNION and UNION ALL, to be sure you use the right one.

Hope this helps,
-- Jon
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating a view combining two columns into one
 
Similar Threads
How to create a tables having One to One relation ship to each other
Hypersonic DB question
Why sql exception happens?
Mapping same POJO to two tables in Hibernate XML mapping files
How to restrict user against marking same event in multiple times