favor
favor

Reputation: 45

MySQL OR question

Is there a way I can use the OR or something similar inside a join, inside the mysql code below.

INNER JOIN users_friends ON users.user_id = users_friends.friend_id OR users_friends.user_id

Upvotes: 4

Views: 76

Answers (5)

user3296888
user3296888

Reputation: 11

INNER JOIN users_friends ON (users.user_id = users_friends.friend_id || users.user_id = users_friends.user_id)

Upvotes: 0

subh
subh

Reputation: 78

Used Many types of this query
INNER JOIN users_friends as U ON (users.user_id = U.friend_id OR U.user_id)

Upvotes: 0

Brian Hooper
Brian Hooper

Reputation: 22044

Don't you mean...

INNER JOIN users_friends ON (users.user_id = users_friends.friend_id OR
                             users.user_id = users_friends.user_id)

Upvotes: 0

Lars
Lars

Reputation: 1466

try:

INNER JOIN users_friends ON (users.user_id = users_friends.friend_id OR users_friends.user_id)

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

INNER JOIN users_friends
    ON users.user_id IN (users_friends.friend_id, users_friends.user_id)

Upvotes: 3

Related Questions