1

I know the question is little ambiguous. I hope I am able to clarify the question here.

I have a table,Table Name: user_group_relation

|--------------------------------------|
| userId | userId_1 | groupId | amount |
|--------------------------------------|
|   3    |     5    |     1   |  0.00  |
|--------------------------------------|

I want to issue a update on the table, so as I have two columns userId and userId_1 which have the userId of two different users.

I have a relation (3,5) is there any way I can look up in the table for this combination where the relation (userId_1, userId) could have been stored as either (3,5) or (5,3)

1 Answer 1

1

Do you mean

SELECT * FROM user_group_relation WHERE (userId_1 = 3 AND userId = 5) 
OR (userId_1 = 5 AND userId = 3);

or

UPDATE user_group_relation set userId_1 = <value>, userId = <value> 
WHERE (userId_1 = 3 AND userId = 5) OR (userId_1 = 5 AND userId = 3);

?

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, exactly! That was what I wish to do! Thanks for the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.