JOIN words_users myself ON (myself.uid IN (g.player1, g.player2) AND myself.uid = s.uid)
JOIN words_users opponent ON (opponent.uid IN (g.player1, g.player2) AND myself.uid <> s.uid)
JOIN words_social s ON (s.uid = myself.uid)
WHERE c.gid = in_gid
AND s.social = in_social
AND s.sid = in_sid
AND (c.uid = myself.uid OR NOT opponent.muted)
ORDER BY c.CREATED ASC;
And get the syntax error which don't quite understand:
ERROR: missing FROM-clause entry for table "s"
LINE 57: ...yself.uid IN (g.player1, g.player2) AND myself.uid = s.uid)
^
Probably because "myself" needs "s" and vice versa?
Well, that is basically why I was going on about the oddity of having social be a part of the main query. Personally I would write it as "myself.uid = in_uid", but you don't have an in_uid to reference. Decide how you want to do something equivalent.