clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335489 fiddles created (27404 in the last week).

CREATE TABLE members ( memberid integer PRIMARY KEY, name varchar(100) ) ;
 hidden batch(es)


INSERT INTO members (memberid, name) VALUES (1, 'member 1'), (2, 'member 2') ;
 hidden batch(es)


CREATE TABLE fees ( memberid integer REFERENCES members(memberid), amountpaid decimal(10,2) NOT NULL, paiddate date NOT NULL ) ;
 hidden batch(es)


INSERT INTO fees (memberid, amountpaid, paiddate) VALUES (1, 100.0, curdate()), (2, 100.0, curdate() - interval 1 month);
 hidden batch(es)


SELECT * FROM fees JOIN members ON fees.memberid = members.memberid;
memberid amountpaid paiddate memberid name
1 100.00 2017-06-24 1 member 1
2 100.00 2017-05-24 2 member 2
 hidden batch(es)


SELECT members.memberid, members.name /* , and anything you need */ FROM members /* JOIN fees ON fees.memberid = members.memberid */ LEFT JOIN /* Imperative to be LEFT JOIN */ ( /* members who paid this month */ SELECT fees.memberid FROM fees WHERE YEAR(paiddate) = YEAR(curdate()) AND MONTH(paiddate) = MONTH(curdate()) ) AS s0 ON s0.memberid = members.memberid WHERE s0.memberid IS NULL /* The LEFT JOIN produced nothing on the right side */
memberid name
2 member 2
 hidden batch(es)