Reputation: 257
Is it possible to SELECT
name and address attribute from names table but at the same time I also want to combine description attribute from info table.
CREATE TABLE names(
ID CHAR(2) PRIMARY KEY
name VARCHAR2(20) NOT NULL
address VARCHAR2(40) NOT NULL
)
CREATE TABLE info (
ID CHAR(2) REFERENCES names
description VARCHAR2(80) NOT NULL
)
I Tried union
method but failed
SELECT name, address
FROM names
UNION
SELECT description
FROM info;
is there any way to do it?
Upvotes: 0
Views: 86
Reputation: 143
select n.name, n.address, i.description from names as n Left join info as i on n.id = i.id
Upvotes: 0
Reputation: 8169
SELECT name, address, description
FROM names JOIN info USING(id)
Upvotes: 2
Reputation: 204766
Yes, it is called a join
SELECT n.name, n.address, i.description
FROM names n
join info i on n.id = i.id
Upvotes: 0
Reputation: 238086
You could use a full outer join
:
SELECT n.name
, n.address
, i.description
FROM names n
FULL OUTER JOIN
info i
ON i.id = n.id
Upvotes: 0