I want to join two tables together combing two fields in table 1 to form composite keys and combining two fields in table 2 to form composite keys.
The primary keys will be dropped because tables get truncated in ETL
CREATE TABLE collection]
(
collectionid INT NOT NULL PRIMARY KEY,
spaceid INT NOT NULL,
collectionpa VARCHAR(150) NOT NULL,
collectionto VARCHAR (150) NOT NULL
)
CREATE TABLE objects
(
birstobj INT NOT NULL PRIMARY KEY
birstspace INT NOT NULL,
collectionid INT NOT NULL,
object_nm VARCHAR(150) NOT NULL,
object_label VARCHAR (150)NOT NULL
)
composite keys in table 1 spaceid and collectionpa composite keys in table 2 birstspace and collectionid
A join condition is just like any other SQL condition - you can use both the columns there:
SELECT *
FROM collection c
JOIN object o ON c.collectionid = o.collectionid AND
c.spaceid = o.birstspace
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.