Here's what I have so far.

Code:
$result = $DB->query("(SELECT f1.member_id as friend_id, f1.request_date, m.*
	                          FROM " . DB_PREFIX . "friends AS f1, " . DB_PREFIX . "members AS m
	                          WHERE f1.friend_id='$member_id' AND f1.member_id=m.member_id AND f1.pending='0' $wheresql)
	                          UNION
	                          (SELECT f2.friend_id, f2.request_date, m.*
	                          FROM " . DB_PREFIX . "friends AS f2, " . DB_PREFIX . "members AS m
	                          WHERE f2.member_id='$member_id' AND f2.friend_id=m.member_id AND f2.pending='0' $wheresql)
	                          ORDER BY username ASC
	                          LIMIT $limit");
Here's my 2 tables.

Table = prefix_friends
Code:
     
 member_id  |  friend_id  | request_date  | pending
  3         |    18       |  1299658055   |  0
  6         |    22       |  1366802565   |  0
  7         |    3        |  1366802566   |  0
Table = prefix_members
Code:
member_id    | group_id | username
   1         |  1       | Tom
   2         |  2       | Betty
   3         |  2       | Gena
   4         |  5       | Richard
   5         |  8       | Angie
   6         |  5       | Keith
   7         |  8       | Lori
What I'm trying to do is retrieve only results that are in group_id 2 and group_id 5. But having difficulty in grasping exactly how to construct the query. If its not asking too much I could sure use some assistance, which would be greatly appreciated.