Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table if exists my_a; drop table if exists my_b;
- create table my_a(id integer primary key,descr text); create table my_b(id integer primary key, more_text text);
- insert into my_a values(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g');
- insert into my_b values(1,'A'),(2,'B'),(5,'E');
- select a.id,a.descr, case when b.id is not null then b.more_text end from my_a a left join my_b b on a.id=b.id;
Add Comment
Please, Sign In to add comment