Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT a.id, a.other, b.baz
- FROM a
- LEFT OUTER JOIN b
- ON a.id = b.id
- AND b.bar = 'foo'
- SELECT a.id, a.other, b.baz
- FROM a
- LEFT OUTER JOIN b
- ON a.id = b.id
- WHERE (b.bar IS NULL OR b.bar = 'foo')
- SELECT a.id, a.other, b.baz
- FROM a
- LEFT OUTER JOIN b
- ON a.id = b.id
- WHERE (b.bar IS NULL OR b.bar = 'foo')
- CREATE TABLE a (id INTEGER, other VARCHAR(32));
- CREATE TABLE b (id INTEGER, bar VARCHAR(32), baz VARCHAR(32));
- insert into A (id, other) values ('1', 'Has foo');
- insert into A (id, other) values ('2', 'Has none');
- insert into A (id, other) values ('3', 'Has foobar');
- insert into B (id, bar, baz) values ('1', 'foo', 'Include');
- insert into B (id, bar, baz) values ('1', 'foobar', 'Exclude');
- insert into B (id, bar, baz) values ('1', 'another', 'Exclude');
- insert into B (id, bar, baz) values ('1', 'More', 'Exclude');
- insert into B (id, bar, baz) values ('3', 'foobar', 'Exclude');
- CREATE TABLE a (id INTEGER, other VARCHAR(32));
- CREATE TABLE b (id INTEGER, bar VARCHAR(32), baz VARCHAR(32));
- insert into A (id, other) values ('1', 'Has foo');
- insert into A (id, other) values ('2', 'Has none');
- insert into A (id, other) values ('3', 'Has foobar');
- insert into B (id, bar, baz) values ('1', 'foo', 'Include');
- insert into B (id, bar, baz) values ('1', 'foobar', 'Exclude');
- insert into B (id, bar, baz) values ('1', 'another', 'Exclude');
- insert into B (id, bar, baz) values ('1', 'More', 'Exclude');
- insert into B (id, bar, baz) values ('3', 'foobar', 'Exclude');
- SELECT a.id, x.baz
- FROM a
- LEFT OUTER JOIN
- (SELECT id, baz FROM b WHERE bar = 'foo') As x ON a.id = x.id
- (Isnull({b.bar}) OR {b.bar} = "foo")
Add Comment
Please, Sign In to add comment