Hi, you need a LEFT JOIN on your query. See http://mysql.com/doc/J/O/JOIN.html Try somthing like:
SELECT m.firstname, m.lastname FROM tbl_membernames as m LEFT JOIN tbl_paid as p ON (m.name_id=p.name_id and p.year=2000) WHERE p.name_id IS NULL On Mon, 2002-04-29 at 09:37, Markus Lervik wrote: > > I've got a problem that's been bothering me for quite some time: > > If I've got two tables, where I list people who's paid their > membership fee, year, etc., and another table with the names > > tbl_membernames : name_id, firstname, lastname > tbl_paid : name_id, year > > how do I get the members who hasn't paid a particular years > fee? > > So I'd somehow need to do something like > > SELECT m.firstname,m.lastname > FROM tbl_membernames AS m, tbl_paid AS p > WHERE (m.name_id=p.name_id AND <<m.name_id isn't in tbl_paid when > tbp_paid.year="2000">>) > > I've tried just about anything I can think about, but nada. > I'd assume that if it's at all possible it'd be some join-trickery, > but I just can't figure it out. > > (yes, I know it'd be easier db-wise to have a 'paid ENUM("y","n")' > -field, but this is just a curiosity. I want to know. ;) > > > Cheers, > Markus > > -- > Markus Lervik > Linux-administrator with a kungfoo grip > Vaasa City Library - Regional Library > [EMAIL PROTECTED] > +358-6-325 3589 / +358-40-832 6709 > -- dsoares (sql) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php