add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table vendor (
id int not null primary key,
name varchar(10) not null
);

create table purchase (
id int not null primary key,
name varchar(10) not null,
vendor_id int
-- , foreign key (vendor_id) references vendor(id)
);

insert into vendor values
(1,'Anna'),
(2,'Bob'),
(9,'TEST');

insert into purchase values
(3,'Louis',null),
(4,'Sara',null),
(5,'Sophie',1),
(6,'John',2);

-----------------------------------------

select p.*, v.id as v_id
from purchase p
inner join vendor v on v.id = p.vendor_id;

select p.*, v.id as v_id
from purchase p
left join vendor v on v.id = p.vendor_id;

select p.*, v.id as v_id
from purchase p
right join vendor v on v.id = p.vendor_id;
3 rows affected
4 rows affected
id name vendor_id v_id
5 Sophie 1 1
6 John 2 2
id name vendor_id v_id
3 Louis null null
4 Sara null null
5 Sophie 1 1
6 John 2 2
id name vendor_id v_id
5 Sophie 1 1
6 John 2 2
null null null 9
id name p_id
1 Anna 5
2 Bob 6
id name p_id
1 Anna 5
2 Bob 6
9 TEST null
id name p_id
null null 3
null null 4
1 Anna 5
2 Bob 6