I have two tables, things
and properties
:
CREATE TABLE things (
id SERIAL PRIMARY KEY
);
CREATE TABLE properties (
thing_id INT,
key TEXT,
value TEXT
);
I want to select from things
and join rows from properties
as columns. For example, say I have the following:
INSERT INTO things DEFAULT_VALUES; -- suppose id is 1
INSERT INTO properties (thing_id, key, value) VALUES
(1, 'height', '5'),
(1, 'width', '6'),
(1, 'length', '7');
How can I select from things with height
, width
, and length
as columns?
Also, I don't want to specifically select height
, width
, and length
, but any rows that may be inside properties.