I guess MySQL's UNION
(Manual) keyword is what you are looking for.
EDIT due to edited question:
You will need a subquery for what you are trying to do (a JOIN
might also work, but would be more complicated):
SELECT firstName, lastName FROM users WHERE ID IN
(
SELECT user1ID AS friendID FROM friends WHERE user2ID = '$userid'
UNION
SELECT user2ID AS friendID FROM friends WHERE user1ID = '$userid'
)
Note that subqueries can cause performance issues in very large tables and/or complicated queries. You may want to refactor the subquery to a JOIN
in that case.