Whats the best way to find out if a value exists within a set of columns on the same table
Say I had a MySQL table which sorts relationships between users (where there is more than 2 columns of users). Whats the best way to check if a user exists in any of a set of columns within the table?
Heres a sample table:
user_relationships('id', 'team', 'teammember1', 'teammember2' 'teammember3' 'teammember4' 'teammember5' 'teammember6' 'teammember7' 'teammem开发者_如何学Pythonber8' 'teammember9');
Thanks in advance, Ferdia
Where teammmeber1=USER OR teammember2=USER OR teammember3=USER.........
I wouldn't make the table look like that... But that's your decision
I would make it look like:
Table - Teams :
id,name,someotherinfo
Table - Team-Members :
team_id, user_id
精彩评论