mysql - sql more than one keys in one field -
i guess, name of question strange, don't know how state correctly, i'll try describe problem. say, have 2 tables:
1)
id | unit_name | strength | health 1 | private | 10 | 10 2 | general | 5 | 5 n | | 123 | 321
2)
id | rules | who_has_this_rule 1 | rule1 | 1 2 | rule2 | 2 3 | rule3 | 1 4 | rule4 | 1
the field "who_has_this_rule" correspondes id of first table. can't figure out if unit should have more 1 rule in profile. example, private should have rule1 , rule4. how this?
what need join table.
a third table join rule , units
unit_rules
id | unit_id | rule_id 1 | 1 | 1 2 | 1 | 4 3 | 2 | 1
you can have primary key(id) or compound key(unit_id , rule_id)
Comments
Post a Comment