All pastes #926623 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-03 19:47 UTC
rendered paste body
matches ( 
	int user1id,
	int user2id
)

users (
	userid,
	int group,
	varchar(50) type
)

SELECT ALL USERS (1st user)


SELECT userid from users U JOIN ((SELECT user1id as u1, user2id as u2 FROM matches) UNION DISTINCT (SELECT user2id as u1, user2id as u2)) as M ON U.userid = M.u1 WHERE group <> $thisusersgroup AND type<>$thisuserstype AND u2 != $user1id

for each user, select * from students where group<>$thisusersgroup AND type<>$thisuserstype (2nd user)


want to check that if user1id is the 1st user and user2id is the 2nd user, this user isn't in the selectable set
similarly if user2id is the 1st user and user1id is the 1st user