开发者

Whats the best way to find out if a value exists within a set of columns on the same table

开发者 https://www.devze.com 2023-03-05 01:40 出处:网络
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?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消