lundi 12 janvier 2015

MySql query - If table two tables have same data, select from more important table


Vote count:

0




I have three tables


rules, default_client_rules and client_rules


Rules contains a list of all the rules, their names, parameters etc.


default_client_rules has a list of rules that applies to all users. Table:



`id`, `rule_id`, `num_required`


The user can also create their own rules stored in client_rules.



`id`, `rule_id, `num_required`


The user can create their own rules that would override the default rules so in my tables I might have:


default_client_rules 21, 3, 0


client_rules 7, 3, 1


The client rules takes precedence over the default client rules table. I want to write a query to display all rules. The bit I'm having trouble with is, in the scenario above when there is an entry in client_rules for the same rule as in default_client_rules I only want to select the client_rules entry.



asked 53 secs ago







MySql query - If table two tables have same data, select from more important table

Aucun commentaire:

Enregistrer un commentaire