Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

QUICKIE MYSQL question

  • 09-09-2005 09:21PM
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    Ive a quick mysql question for one of u gurus

    I've three tables relating to members that would sign up to commissions:



    Commissiontable
    id
    title
    etc etc


    Linktable
    id
    commissionid
    memberid



    Memebertable
    id
    name
    etc etc

    I know how to select all members that are on the commission:

    SELECT m.id,m.name FROM Memebertable as m RIGHT JOIN Linktable as l ON (m.id=l.memberid) WHERE l.commissionid='the current commission'

    However how do i select all members that ARE NOT on the commission???


    Tnx


Comments

  • Registered Users, Registered Users 2 Posts: 304 ✭✭PhantomBeaker


    Ok, I'm hoping you're using MySQL 4.1 because version 4.1 and up supports nested queries which is what you need.

    I'd use something like (I've not tested this but this is the general gist)
    [php]
    SELECT m.id,m.name
    FROM Memebertable as m
    WHERE m.id <> all(SELECT m.id FROM Memebertable as m RIGHT JOIN Linktable as l ON (m.id=l.memberid) WHERE l.commissionid='the current commission')
    [/php]

    What that does is, it gets all the members from the table and excludes those who are on that commission using that query that you created to get all those members on commission)

    Take care,
    Aoife


Advertisement